1. Download the two packages required to expand SSH, Libssh2 and SSH2.
Libssh2:http://pan.baidu.com/s/1hq7xohu
LIBSSH2 Official website: http://www.libssh2.org/download/
Ssh2:http://pan.baidu.com/s/1bnhdayb
SSH2 Official website: HTTP://PECL.PHP.NET/PACKAGE/SSH2
2, Installation Libssh2
1 tar -zxvf libssh2. Tar . GZ 2 CD Libssh2 3 ./configure--prefix=/usr/local/libssh24make makeinstal
3, Installation Ssh2
1 tar -zxvf ssh2.tgz2cd SSH23phpize4 ./configure-- Prefix=/usr/local/ssh2--with-ssh2=/usr/local/libssh25 make
4. Copy the generated ssh2.so file to the extended directory specified in the php.ini
The contents of php.ini are: Extension_dir =/usr/local/php/ext/
Extension_dir is an expanded directory of PHP configuration
In the php.ini file, look for the location of the Extension_dir, assuming:/usr/local/php/ext/, then you can execute the following command
1 CP ssh2.so/usr/local/php/ext/
5, modify the content of php.ini
Add content to php.ini:extension=ssh2.so
6. Restart Apache
1 Service httpd restart
7, check whether the installation is successful, and simply use SSH extension.
1. See if you have installed
1 <? PHP 2 Phpinfo (); // if SSH2 is already installed, the page will prompt you to expand the Ssh2
2, simple use SSH2
1 <? PHP 2 $connection = ssh2_connect (' 202.112.113.250 '); 3 $flag = Ssh2_auth_password ($connection, "root", "root"); 4 Var_dump ($flag);
SSH2 's Help document: http://php.net/manual/zh/ref.ssh2.php
Note: When installing LIBSSH2, it went well, but when installing SSH2, I encountered various errors. This situation may be ssh2 and LIBSSH2 version incompatibility, at this time, you should go to the official website to download other versions.
PHP Extended SSH functionality