适用于PHP7 MacOS的SSH2? [英] SSH2 for PHP7 MacOS?
问题描述
尝试使用
ssh2_sftp($this->con);
PHP 7.1.7认为Im正在类中寻找函数.经过一番阅读后,我发现需要从PECL安装SSH2 ( http://php.net/manual/zh/wrappers.ssh2.php)
PHP 7.1.7 thinks Im looking for a function in the class. After some reading, I found that SSH2 needs to be installed from PECL ( http://php.net/manual/en/wrappers.ssh2.php )
当我这样做时,出现以下错误:
When I went to do that, I got the following error:
pecl/ssh2 requires PHP (version >= 4.0.0, version <= 6.0.0), installed version is 7.1.7
No valid packages found
install failed
任何人都对如何使其在PHP 7.1.7的MacOs 10.13.3(17D47)上运行有任何想法? 预先感谢!
Anyone have any ideas on how to get this to run on MacOs 10.13.3 (17D47) with PHP 7.1.7? Thanks in advance!
推荐答案
我终于在MacOS Mohave上找到了解决方案.我有Homebrew安装的PHP 7.3:
I finally found a solution on MacOS Mohave. I have PHP 7.3 installed by Homebrew:
brew install php
brew install libssh2
从最新来源安装ssh2 pecl扩展的开发版本:
Install development version of ssh2 pecl extension from the latest sources:
cd ~/Downloads
git clone https://git.php.net/repository/pecl/networking/ssh2.git
cd ssh2
phpize
./configure
make
make install
在php.ini
中启用扩展名.您可以使用TextEdit:
Enable extension in php.ini
. You can use Text
open -e /usr/local/etc/php/7.3/php.ini
在文件的开头添加extension="ssh2.so"
并保存.
Add extension="ssh2.so"
to the beginning of the file and save.
测试结果:
php -i | grep libssh2
您应该看到
libssh2 version => 1.9.0
这篇关于适用于PHP7 MacOS的SSH2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!