cPanel: Install PHP SSH2 Module

One of my developer required PHP SSH2 module to be loaded into the cPanel server. Since this module is not available inside EasyApache, I need to install it separately and integrate to the current configuration that we have build using EasyApache.

1. Download and install libssh2 from this website,

$ cd /usr/local/src
$ wget
$ tar -xzf libssh2-1.4.0-20120319.tar.gz
$ cd libssh2-*
$ ./configure
$ make all install

2.  Before we install ssh2 module, we need to know where the PHP extension_dir location:

$ php -i | grep extension_dir

3. Then, download PECL ssh2 module from here, and install the module:

$ cd /usr/local/lib/php/extensions/no-debug-non-zts-20090626
$ wget
$ tar -xzf ssh2-0.11.3.tgz
$ mv ssh2-0.11.3 php-ssh2
$ cd php-ssh2
$ phpize
$ ./configure --with-ssh2
$ make
$ make install

4. Now we need to enable the module in php.ini. Retrieve the php.ini location:

$ php -i | grep "Loaded Configuration File"
 Loaded Configuration File => /usr/local/lib/php.ini

And run following command to map the extension into PHP:

$ echo "" >> /usr/local/lib/php.ini

5. Restart Apache web server (if you are using DSO):

$ service httpd restart

Done! You can check if SSH2 module is loaded or not by using following command:

$ php -i | grep ssh2
Registered PHP Streams => compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip,, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp
libssh2 version => 1.4.0-20120319
banner => SSH-2.0-libssh2_1.4.0-20120319
PWD => /usr/local/lib/php/extensions/no-debug-non-zts-20090626/php-ssh2
_SERVER["PWD"] => /usr/local/lib/php/extensions/no-debug-non-zts-20090626/php-ssh2
_ENV["PWD"] => /usr/local/lib/php/extensions/no-debug-non-zts-20090626/php-ssh2

11 thoughts on “cPanel: Install PHP SSH2 Module

  1. estou muito agradecido pelo seu tutorial, me ajudou bastante, sou do Brasil. Sucesso!


    1. Thanks Aldemir, even though i dont speak Brasil but Google translate helped me a lot. 🙂


  2. I so fucking love you for this. Do you know how long I have been waiting for this? Now I dont just have to make a second vps and install ssh2 and php. You have saved me so much money time and effort.

    Seriously Thank You,

    Justin Poland


  3. If you use Cpanel + Cloudlinux with PHP Selector then this extension can be selected by the end user (and other modules as well).


  4. cPanel in EasyApache 4

    Not Working …

    /opt/cpanel/ea-php56/root/usr/bin/pecl install ssh2



    ./configure –with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config –with-ssh2


    make install


Leave a Reply

Your email address will not be published. Required fields are marked *