0

I am facing the following error while trying to install ssh2 extension with pecl:

17 warnings and 3 errors generated.
make: *** [ssh2_fopen_wrappers.lo] Error 1
ERROR: `make' failed

Here is what I've done:

brew install php
brew install libssh2
pecl install ssh2-1.1.2

That installed php 7.3.3, libssh2 1.8.0 and failed to install ssh2-1.1.2.
Does anyone have a solution for the problem? Thank you!

Related links:
https://github.com/docker-library/php/issues/767
Install PECL SSH2 extension for PHP

Vitalii Isaenko
  • 941
  • 1
  • 14
  • 37

4 Answers4

9

My original answer: SSH2 for PHP7 MacOS?

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://github.com/php/pecl-networking-ssh2.git
cd pecl-networking-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 version'

You should see

libssh2 version => 1.10.0

-- EDIT for Apple silicon (M1)

Homebrew uses different path on Apple silicon machines and ./configure command fails with error: "checking for ssh2 files in default path... not found". I resolved this with setting custom path:

./configure --with-ssh2=/opt/homebrew/opt/libssh2
Peter Knut
  • 2,311
  • 20
  • 15
0

Try to install libssh2-1-dev

brew install libssh2-1-dev

Update pecl

pecl channel-update pecl.php.net

And then install ssh2-1.1.2

brew install ssh2-1.1.2

This is how it worked for me

Andrei Lupuleasa
  • 2,677
  • 3
  • 14
  • 32
0
brew install libssh2
pecl install ssh2-1.1.2
jpswade
  • 327
  • 2
  • 10
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](https://stackoverflow.com/help/how-to-answer). – Tyler2P Aug 23 '22 at 18:23
  • I think this is called gate keeping. – jpswade Aug 24 '22 at 19:06
-1

You can use this answer about 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
Konorlevich
  • 65
  • 1
  • 4