我在尝试使用PECL安装ssh2
扩展时面临以下错误:
17 warnings and 3 errors generated.
make: *** [ssh2_fopen_wrappers.lo] Error 1
ERROR: `make' failed
这是我所做的:
brew install php
brew install libssh2
pecl install ssh2-1.1.2
安装了php 7.3.3,libssh2 1.8.0,无法安装SSH2-1.1.2。
有人有解决问题的解决方案吗?谢谢!
相关链接:
https://github.com/docker-library/php/sissues/767
安装PHP
我的原始答案:php7 macos的SSH2?
我终于在Macos Mohave上找到了解决方案。我有由Homebrew安装的PHP 7.3:
brew install php
brew install libssh2
从最新来源安装SSH2 PECL扩展的开发版本:
cd ~/Downloads
git clone https://github.com/php/pecl-networking-ssh2.git
cd pecl-networking-ssh2
phpize
./configure
make
make install
在php.ini
中启用扩展。您可以使用textedit:
open -e /usr/local/etc/php/7.3/php.ini
将extension="ssh2.so"
添加到文件的开头并保存。
测试结果:
php -i | grep 'libssh2 version'
您应该看到
libssh2 version => 1.10.0
- 为苹果硅(M1)编辑
Homebrew在Apple Silicon机器上使用不同的路径,并且./configure命令失败,错误:"检查默认路径中的SSH2文件...找不到&quot。我通过设置自定义路径解决了这一点:
./configure --with-ssh2=/opt/homebrew/opt/libssh2
尝试安装libssh2-1-dev
brew install libssh2-1-dev
更新pecl
pecl channel-update pecl.php.net
然后安装ssh2-1.1.2
brew install ssh2-1.1.2
这就是它对我有效的方式
brew install libssh2
pecl install ssh2-1.1.2
您可以使用有关Docker的答案
brew install libssh2-1-dev
cd /tmp && git clone https://git.php.net/repository/pecl/networking/ssh2.git && cd /tmp/ssh2
phpize && ./configure && make && make install
echo "extension=ssh2.so" > /usr/local/etc/php/conf.d/ext-ssh2.ini
rm -rf /tmp/ssh2