簡體   English   中英

如何為 php 7.3 安裝 ssh2

[英]How to install ssh2 for php 7.3

嘗試通過 pecl 安裝擴展 ssh2 時,我遇到以下錯誤消息。 我使用的是基於php:7.3.2-fpm的 docker 容器

重現步驟:

  • 安裝 PHP 7.3.2
  • 安裝軟件包libssh2-1-devlibssh2-1
  • 嘗試通過pecl install ssh2-1.1.2安裝 ssh2 擴展

那么如何才能成功安裝ssh2擴展呢?

...

/tmp/pear/temp/ssh2/ssh2_fopen_wrappers.c: In function 'php_ssh2_fopen_wrapper_tunnel':
/tmp/pear/temp/ssh2/ssh2_fopen_wrappers.c:1265:42: error: invalid operands to binary == (have 'zend_string {aka struct _zend_string}' and 'int')
  if (resource->path && resource->path[0] == '/') {
                        ~~~~~~~~~~~~~~~~~ ^~
/tmp/pear/temp/ssh2/ssh2_fopen_wrappers.c:1268:8: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
   host = resource->path + 1;
        ^
Makefile:196: recipe for target 'ssh2_fopen_wrappers.lo' failed
make: *** [ssh2_fopen_wrappers.lo] Error 1
ERROR: `make' failed

當我第一次用 google 搜索這個問題時,我發現這個問題沒有答案並暫停了超級用戶。 我認為它更適合這里。

有一個關於bugs.php.net的現有報告,用戶goldorakhong評論說從源代碼編譯它。

使用 docker 文件可以這樣做:

RUN cd /tmp \
    && git clone https://git.php.net/repository/pecl/networking/ssh2.git \
    && cd /tmp/ssh2/ \
    && .travis/build.sh \
    && docker-php-ext-enable ssh2

如果您不使用 docker,則需要替換docker-php-ext-enable以其他方式注冊變量。

Windows 2008 R2 64 位

Wampserver 3.1.9 64 位

PHP 7.3.12

1 - 從https://windows.php.net/downloads/pecl/releases/ssh2/下載 php_ssh2.dll 和 php_ssh2.pdb

2 - 選擇 2019 年 9 月 18 日上午 11:50 1.2

3 - 選擇 9/18/2019 10:45 AM 438049 php_ssh2-1.2-7.3-ts-vc15-x64.zip

4 - 解壓並復制 php_ssh2.dll 和 php_ssh2.pdb 到 C:/wamp64/bin/php/php7.3.12/ext/

5 - 在 php.ini 插入行:extension=php_ssh2.dll

6 - 在 wamp 中重啟所有服務

暫無
暫無

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

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