簡體   English   中英

如何在 Centos 上安裝 ssh2?

[英]How to install ssh2 on Centos?

我想在 Linux 服務器上安裝 ssh2,使用 Centos 7 和 PHP 7.3

嘗試了以下步驟:

  1. yum 安裝 gcc php-devel libssh2 libssh2-devel php-pear make

  2. pecl 安裝 -f ssh2

第 2 步給出了錯誤

第 2 步錯誤

步驟 2 錯誤 p2

以下是一些錯誤

/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);

我不會去仔細檢查這個,但我希望你有一個錯誤的 PHP 版本用於那個庫 PHP 包裝器。

我在同一個系統上遇到了同樣的問題。 在這里,我成功地安裝了 ssh2。

  1. 安裝必要的軟件包:

    • [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
  2. 安裝 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
  3. 從 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
  4. 在 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
  5. 檢查擴展是否可用

    • [root@lepc ~]# php -m | grep ssh2
    • [root@lepc ~]# ssh2

    或者另一種方式:

    • [root@lepc ~]# ls /usr/lib64/php/modules/ | grep ssh2.so
    • [root@lepc ~]# ssh2.so

也許晚了,但希望這會對某人有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM