博客原文地址https://xgs888.top/post/view?id=58
Call to undefined function sftp\ssh2_connect()centos安装php的ssh2扩展
事先准备需要的
libssh2 下载 wget https://www.libssh2.org/download/libssh2-1.8.0.tar.gz
ssh2下载 wget wget http://pecl.php.net/package/ssh2/ssh2-1.1.2.tgz
cd /usr/loca/src wget https://www.libssh2.org/download/libssh2-1.8.0.tar.gzwget http://pecl.php.net/package/ssh2/ssh2-1.1.2.tgz //解压 tar -zxvf libssh2-1.8.0.tar.gz cd libssh2-1.8.0 //编译到libssh2 ./configure --prefix=/usr/local/libssh2 make && make install #解压ssh2 tar -zxvf ssh2-1.1.2.tgz 解压的时候报错看了一下文件类型是XHTML 最后在桌面解压好上传的 cd ssh2-1.1.2 phpize 结果报错如下
Can't find PHP headers in /usr/include/php The php-devel package is required for use of this command
直接安装php-dev
yum install php55w-del ;//PHP版本是5.5的
执行phpize
./configure --prefix=/usr/local/ssh2 --with-ssh2=/usr/local/libssh2
结果都是报错,上官网看了一下,原来是ssh2-1.0yi以上版本是PHP7.0
下载0.12版本
cd ssh2-0.12/ phpize ./configure --prefix=/usr/local/ssh2 --with-ssh2=/usr/local/libssh2 //复制ssh2.so 到 /usr/lib64/php/modules/ ///usr/lib64/php/modules/ php扩展目录 cp modules/ssh2.so /usr/lib64/php/modules/ vi /etc/php.ini 添加 extension=ssh2.so 上面就ok了 查询一下 php -i|grep ssh2