SSH2 for PHP7 MacOS?

自闭症网瘾萝莉.ら 提交于 2019-12-05 16:04:26
Nigel Atkinson

I managed to install php-ssh2 on MacOS High Sierra.

First I had to install libssh2, in order for PECL to compile the extension.

I used brew, however most likely libssh2 is available from mac ports also.

brew install libssh2

and then

pecl install ssh2-1.1.2

I have the Xcode command line tools (already) installed - which I assume was needed to compile the extension.

I finally found a solution on MacOS Mohave. I have PHP 7.3 installed by Homebrew:

brew install php
brew install libssh2

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

Enable extension in php.ini. You can use TextEdit:

open -e /usr/local/etc/php/7.3/php.ini

Add extension="ssh2.so" to the beginning of the file and save.

Test the result:

php -i | grep libssh2

You should see

libssh2 version => 1.9.0

Try this:

pecl install ssh2-1.1.2

You can see available versions for ssh2 HERE

For those using alpine linux, make sure to add libssh2-dev first:

apk --update add libssh2-dev
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!