Please follow the below steps to add ssh2 extension in PHP.
(Note: You will have to execute the belows commands as root user)
1. Enter directory with PHP version for which you would like to create ssh2 extension
For PHP 5.6 -> /usr/local/apps/php56/bin/
For PHP 7.0 -> /usr/local/apps/php70/bin/
For PHP 7.1 -> /usr/local/apps/php71/bin/
Command:
Code cd /usr/local/apps/php56/bin/
2. Download the extension package
For PHP 5.6 use the below command:
For PHP 7.0 & above:
3. Untar / Unzip extension package and enter is directory
For PHP 5.6:-
Code tar -xvf ssh2-0.13.tgz
cd ssh2-0.13.tgz
For PHP 7.0 & above:-
Code unzip php7.zip
cd pecl-networking-ssh2-php7
4. Run phpize
For PHP 5.6 -> /usr/local/apps/php56/bin/phpize
For PHP 7.0 -> /usr/local/apps/php70/bin/phpize
For PHP 7.1 -> /usr/local/apps/php71/bin/phpize
(if any error occurs run yum or apt-get install autoconf)
5. Configure with providing paths to php-config and libssh library path
For PHP 5.6:
Code ./configure --with-php-config=/usr/local/apps/php56/bin/php-config --with-ssh2=/usr/local/apps/
For PHP 7.0:
Code ./configure --with-php-config=/usr/local/apps/php70/bin/php-config --with-ssh2=/usr/local/apps/
For PHP 7.1:
Code ./configure --with-php-config=/usr/local/apps/php71/bin/php-config --with-ssh2=/usr/local/apps/
6. Run it's compilation and installation
7. Now move the compiled extension to the extension directory
For PHP 5.6:
Code mv /usr/local/apps/php56/lib/extensions/no-debug-non-zts-20131226/ssh2.so /usr/local/apps/php56/ext/
For PHP 7.0:
Code mv /usr/local/apps/php70/lib/extensions/no-debug-non-zts-20151012/ssh2.so /usr/local/apps/php70/ext/
For PHP 7.1:
Code mv /usr/local/apps/php71/lib/extensions/no-debug-non-zts-20160303/ssh2.so /usr/local/apps/php71/ext/
8. Now add the extension in the extra.ini file for loading the extension in the PHP
For PHP 5.6:
Code echo "extension=ssh2.so" >> /usr/local/apps/php56/etc/php.d/extra.ini
For PHP 7.0:
Code echo "extension=ssh2.so" >> /usr/local/apps/php70/etc/php.d/extra.ini
For PHP 7.1:
Code echo "extension=ssh2.so" >> /usr/local/apps/php71/etc/php.d/extra.ini
9. Now restart the Web Server and PHP service from the Webuzo Panel. Please refer to the below guide to restart the service:
Restart Service Guide
Edited by nikhil89 : February 2, 2018, 10:31 am |