I run sudo apt-get install libssh2-1-dev libssh2-php I get:

Reading package lists... Done
Building dependency tree
Reading state information... Done
libssh2-php is already the newest version.
libssh2-1-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 71 not upgraded.

But it does not work. I don't see them installed when run php -m |grep ssh2 #you should see ssh2

What steps would you take next? One thing to note that when I ran sudo apt-get update I noticed that it's connecting to http://archive.ubuntu.com trusty/multiverse . Could that be an issue?

  • Check your php.ini file
    – symcbean
    Commented Nov 4, 2017 at 17:40

2 Answers 2


To install ssh2 extension for PHP5 , run:

sudo apt-get install gcc make autoconf libc-dev pkg-config php5-dev
sudo pecl install ssh2-0.13


sudo pecl install https://pecl.php.net/get/ssh2-0.13.tgz

Restart the php-fpm service then verify it:

php -i | grep ssh2

pecl : ssh2

  • I followed the instruction and the modules are available when I run php through apache. But not when I run php from command line. Any suggestions? Commented Nov 6, 2017 at 16:24
  • Usually there are 2 configuration files for PHP (php.ini) one for Apache and one for console (CLI). This means that Apache's configuration loads the extension while the console one don't. Check /etc/php folder for them.
    – Alex
    Commented Sep 19, 2018 at 7:53

PHP-5.X + PHP-7.X Installation Instructions cover the difference.

It appear you must use a pecl install procedure when using PHP-5.X versions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .