#下载文件
cd ~
wget http://pecl.php.net/get/ssh2-1.3.1.tgz
tar xvf ssh2-1.3.1.tgz
cd ssh2-1.3.1
#编译&安装
/usr/local/opt/php@7.4/bin/phpize
./configure --prefix=/usr/local/ssh2 --with-ssh2=/usr/local/Cellar/libssh2/1.11.0_1 --with-php-config=/usr/local/opt/php@7.4/bin/php-config
make && make install
#复制共享库到指定扩展文件夹&添加自动加载扩展配置文件到指定文件夹
cp ~/ssh2-1.3.1/modules/ssh2.so /usr/local/opt/php@7.4/lib/php/20190902
cd /usr/local/etc/php/7.4/conf.d
touch ext-ssh2.ini
#在ext-ssh2.ini输入下面的内容
#[ssh2]
#extension="/usr/local/opt/php@7.4/lib/php/20190902/ssh2.so"
#重启php-fpm 并 检查是否安装完毕
/usr/local/opt/php@7.4/sbin/php-fpm restart
php -m | grep ssh2