Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

The first thing you need to check is if your system has SSH2 features or not. You can simply check at phpinfo() in php function. If not, you can simply install SSH2 functions by below commands in root permission. The below case is based on  Centos7.

Code Block
# yum update
#yum yum-y install make gcc libssh2 php-devel php-pear libssh2-devel

The next action you should do is installing ssh2 extension using pecl command for auto detect and download it once hit enter.

Code Block
# pecl install -f ssh2

When you run above command, you may get the message like below

...

That means you should do it in order to make it work like below

Code Block
# echo "extension=ssh2.so" > /etc/php.d/50-ssh2.ini


or


# echo "extension=ssh2.so" > /etc/php.ini

If above works correctly, you should restart your server like

Code Block
# systemctl restart httpd.service

...

Now you can run your command by web or command line like below

Code Block
$ php reboot.php


Example 2) Get command result and display it

...

Now you can run your command by web or command line like below

Code Block
$ php dir.php