Where does ssh2 for php need to be installed?

1k Views Asked by At

Trying to install ssh2 onto a litespeed server and using the traditional install methods are not working for me. I have successfully installed ssh2 into the /etc/php/cli and it works from the command line. However my litespeed server is using the php.ini from the directory /usr/local/lsws/lsphp74/etc/7.4/litespeed/php.ini. I confirmed that by running phpinfo() from the browser and looking at the Loaded Configuration File entry which shows /usr/local/lsws/lsphp74/etc/php/7.4/litespeed/php.ini. No matter what I try and what examples or steps provided to me, I cannot get it to install in an area that I can use via the browser. I do see this line "/usr/local/lsws/lsphp74/etc/php/7.4/mods-available/50-ssh2.ini," in the Additional .ini files parsed section of the phpinfo() page however no matter what I have tried, I cannot get it so show up like its installed when I view the phpinfo() page.

1

There are 1 best solutions below

0
Eric On

This works for LSPHP81 with SSH2, feel free to replace the PHP version with your current version.

1 - Install necessary PHP packages and ssh2 lib

apt-get update
apt-get install lsphp81-pear lsphp81-dev -y
apt-get install libssh2-1 libssh2-1-dev -y

2 - Download SSH2 package from pecl

wget https://pecl.php.net/get/ssh2-1.3.1.tgz
tar -zxvf ssh2-1.3.1.tgz
cd ssh2-1.3.1

3 - Compile ssh2 package

/usr/local/lsws/lsphp81/bin/phpize
./configure --with-ssh2=/usr/local/lsws/lsphp81 --with-php-config=/usr/local/lsws/lsphp81/bin/php-config
make
make install
echo "extension=ssh2.so" >> /usr/local/lsws/lsphp81/etc/php/8.1/mods-available/ssh2.ini

4 - Reload lsws and PHP

systemctl restart lsws
killall lsphp

5 - Result enter image description here