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