我想在Linux服务器上使用Centos 7和PHP 7.3安装ssh2
尝试以下步骤:
yum install gcc php-devel libssh2 libssh2-devel php-pear make
pecl install -f ssh2
第2步出错了
有些错误
/var/tmp/ssh2/ssh2.c:312:2: error: too many arguments to function 'zend_hash_fin d'
if (zend_hash_find(ht, method, method_len + 1, (void**)&value) == FAILURE) {
^
In file included from /usr/include/php/Zend/zend.h:32:0,
from /usr/include/php/main/php.h:33,
from /var/tmp/ssh2/ssh2.c:25:
^
/var/tmp/ssh2/ssh2.c: In function 'php_ssh2_session_connect':
/var/tmp/ssh2/ssh2.c:338:2: error: too few arguments to function 'php_network_co nnect_socket_to_host'
socket = php_network_connect_socket_to_host(host, port, SOCK_STREAM, 0, &tv, N ULL, NULL, NULL, 0 TSRMLS_CC);
^
In file included from /usr/include/php/ext/standard/file.h:22:0,
from /var/tmp/ssh2/ssh2.c:27:
/var/tmp/ssh2/ssh2.c:374:3: error: too many arguments to function 'zend_hash_fin d'
if (zend_hash_find(HASH_OF(methods), "client_to_server", sizeof("client_to_se rver"), (void**)&container) == SUCCESS &&
^
In file included from /usr/include/php/Zend/zend.h:32:0,
from /usr/include/php/main/php.h:33,
from /var/tmp/ssh2/ssh2.c:25:
/usr/include/php/Zend/zend_hash.h:166:30: note: declared here
ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *k ey);
^
/var/tmp/ssh2/ssh2.c:390:3: error: too many arguments to function 'zend_hash_fin d'
if (zend_hash_find(HASH_OF(methods), "server_to_client", sizeof("server_to_cl ient"), (void**)&container) == SUCCESS &&
^
In file included from /usr/include/php/Zend/zend.h:32:0,
from /usr/include/php/main/php.h:33,
from /var/tmp/ssh2/ssh2.c:25:
/var/tmp/ssh2/ssh2.c:496:46: error: macro "add_assoc_string" passed 4 arguments, but takes just 3
add_assoc_string(return_value, "kex", kex, 1);
答案 0 :(得分:0)
我不会再仔细检查一次,但是我希望您对该库PHP包装器使用的PHP版本错误。
答案 1 :(得分:0)
我在同一系统上遇到了同样的问题。在这里,我成功安装了ssh2。
安装必要的软件包:
[root@lepc ~]# yum -y install make gcc glibc-devel zlib-devel openssl-devel
[root@lepc ~]# yum -y install --enablerepo=epel,remi,remi-php73 php-devel
安装libssh2:
[root@lepc ~]# wget https://www.libssh2.org/download/libssh2-1.9.0.tar.gz
[root@lepc ~]# tar vxzf libssh2-1.9.0.tar.gz
[root@lepc ~]# cd libssh2-1.9.0
[root@lepc ~]# ./configure
[root@lepc ~]# make
[root@lepc ~]# make install
从pecl安装ssh2:
[root@lepc ~]# wget https://pecl.php.net/get/ssh2-1.2.tgz
[root@lepc ~]# tar vxzf ssh2-1.2.tgz
[root@lepc ~]# cd ssh2-1.2
[root@lepc ~]# phpize
[root@lepc ~]# ./configure --with-ssh2
[root@lepc ~]# make
[root@lepc ~]# make install
在PHP 7.3中启用ssh2扩展名:
[root@lepc ~]# echo "extension=ssh2.so" > /etc/php.d/ssh2.ini
或者,如果那里没有ssh2.ini文件,则可以执行以下操作:[root@lepc ~]# echo "extension=ssh2.so" > /etc/php.d/php.ini
检查扩展名是否可用
[root@lepc ~]# php -m | grep ssh2
[root@lepc ~]# ssh2
或者另一种方式:
[root@lepc ~]# ls /usr/lib64/php/modules/ | grep ssh2.so
[root@lepc ~]# ssh2.so
也许晚了,但希望这对某人有帮助。