Preface: It needs to be downloaded from other servers to our server through sftp. When executing, the php ssh2_connect() function reports an error of undefined, because the SSH extension is not installed
Landlord php version 7.1.16
1. First, install libssh2
wget --no-check-certificate https://www.libssh2.org/download/libssh2-1.2.tar.gz (https方式记得加上--no-check-certificate)
tar -zxvf libssh2-1.2.tar.gz
cd libssh2-1.2
./configure --prefix=/usr/work/tool/libssh2
make && make install 安装即可
2. Install ssh2
wget http://pecl.php.net/get/ssh2-1.1.2.tgz
tar -xvf ssh2-1.1.2.tgz
cd ssh2-1.1.2
phpize
./configure --prefix=/usr/work/tool/ssh2 --with-ssh2=/usr/work/tool/libssh2 --with-php-config=/usr/work/tool/php/bin/php-config
make && make install
3. Enable the extension
Modify php.ini to add extension=ssh2.so and restart php
4. Confirm to enable
php -m | grep 'ssh2'