1. 安裝libssh2
wget http://www.libssh2.org/download/libssh2-1.4.2.tar.gz
tar -xzvf libssh2-1.4.2.tar.gz
cd libssh2-1.4.2
./configure --prefix=/usr/local/packagist/libssh2
make
make install
如果報錯configure: error: cannot find OpenSSL or Libgcrypt, try --with-libssl-prefix=PATH or --with-libgcrypt-prefix=PATH
分析
openssl安裝的不是標準目錄
解決
手動指定openssl安裝的目錄
# 建軟連
ln -s /usr/local/Cellar/openssl/1.0.2p /usr/local/openssl
./configure --prefix=/usr/local/libssh2 CPPFLAGS="-I/usr/local/openssl/include/" LDFLAGS="-L/usr/local/openssl/lib"
2. 安裝ssh2
## php7 安裝ssh2 要指定版本1.0,否則會報錯
pecl install ssh2-1.0