Main menu

Installing SSH2 Extension for PHP on CentOS

Install the necessary packages to build SSH2 extension

yum install gcc php-devel php-pear libssh2 libssh2-devel
pecl install -f ssh2

you will see output like this..

Starting to download ssh2-0.12.tgz (26,223 bytes)
 .........done: 26,223 bytes
 6 source files, building
 running: phpize
 Configuring for:
 PHP Api Version: 20100412
 Zend Module Api No: 20100525
 Zend Extension Api No: 220100525
 libssh2 prefix? [autodetect]
 Build process completed successfully
 Installing '/usr/lib64/php/modules/'
 install ok: channel://
 configuration option "php_ini" is not set to php.ini location
 You should add "" to php.ini

Add extension in PHP configuration file.

echo >> /etc/php.ini

Restart Apache service to load new PHP configuration

/etc/init.d/httpd restart
 systemctl restart httpd.service

Verify that SSH2 extension is installed for PHP

php -m | grep ssh2