SSH2 在 PHP 7.3.0 上运行错误的解决方法

SSH2 在 PHP 7.3.0 上运行错误的解决方法

用传统的 pecl 方式安装 ssh2,提示无法安装

WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
pecl/ssh2 requires PHP (version >= 4.0.0, version <= 6.0.0), installed version is 7.3.0RC5
No valid packages found
install failed

原因是 PECL 下载的是稳定版本的 SSH2,而稳定版是 0.x.x 了,和 PHP 7 不兼容,无法使用。

于是我又尝试将之前我在 PHP 7.2.7 编译的 SSH2 扩展复制过来,结果运行不了

PHP Warning: PHP Startup: ssh2: Unable to initialize module
Module compiled with module API=20170718
PHP compiled with module API=20180731
These options need to match
in Unknown on line 0
PHP 7.3.0RC5 (cli) (built: Nov 14 2018 00:01:34) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies

重新尝试了编译一下也发现不行

./configure --with-php-config=/usr/local/php/bin/php-config
make

报错

make: *** [Makefile:196: ssh2_fopen_wrappers.lo] Error 1

后来再想了一下,难道是 API 版本不对吗?

果然还真的是这个问题,删掉已经 configure 过的 ssh2 源码包,重新解压再编译

rm -rf ssh2-1.1.2/
tar xzvf ssh2-1.1.2.tgz
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make -j 64
make install

编译成功~

[PHP Modules]
bcmath
Core
ctype
curl
date
dba
dom
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
ssh2
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
yaml
zlib

原创文章,作者:修行黑钻VIP永久会员,如若转载,请注明作者昵称:修行黑钻VIP永久会员及出处:https://www.xiuxingstudio.com/computer/technical-information/2933.html

(0)
上一篇 2022年2月6日 18:55
下一篇 2022年2月9日

相关推荐

发表回复

登录后才能评论
在线客服 QQ交流群
返回顶部