So I have a class that I build that uses the ssh2 package in php. I have successfully set this up and used and tested this class on apache2 server. The server at work where this is going to be running is an instance of litespeed. I have scoured the web for a way to get ssh2 working with this litespeed server however I cannot for the life of me figure it out. I get ssh2_connect() function not found. If I go go /etc/php/... I can see that the ssh2.ini file exists. However I believe the active php instance is located /usr/local/lsws/lsphp74/7.4/etc/php/ where I do not see the ss2.ini located. Is there a way to get ssh2 installed in the directory that is being used by the server? If I run ssh2_connect at the command prompt, it works just fine as it is most likely using the /etc/php instance of php.
ssh2 ssh2_connect() function not found
1k Views Asked by Beanno1116 At
2
There are 2 best solutions below
2

You're correct, ssh2_connect()
is provided by a pecl extension. These are optional binary add-ons for php. I'd make a quick phpinfo();
page and add it to the litespeed server so you can see what modules are active and where the config files php is using are actually located on disk.
The install guide can walk you through installing this pecl extension. https://www.php.net/manual/en/ssh2.requirements.php
Another way to accomplish this is with a pure-php library that doesn't depend on special plug-ins. phpseclib fully implements the ssh protocol in pure php, taking advantage of libraries if they are present but it's able to function without them.
since you didn't mention what exactly is your server env
I would assume it's either OpenLiteSpeed image , or CyberPanel image
first of all , compile libssh2
then compile the PHP extension
and finally , restart lsphp process to load new module
or
then verify by
phpinfo();
to make sure you see ssh2 loaded