1

I've been trying to install the SSH2 libraries for php onto a web server running CentOS 5 with PHP 5.1.6 and was able to successfully install all the dependencies, but after restarting the web server I get the following error:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - libssh2.so.1: cannot open shared object file: No such file or directory in Unknown on line 0

Has anyone run into this before? The ssh2.so file exists at '/usr/lib64/php/modules/ssh2.so' and has the same file permissions as all the other extensions (-rwxr-xr-x).

Thanks

hakre
  • 193,403
  • 52
  • 435
  • 836

2 Answers2

-1

The key to the error is this:

libssh2.so.1: cannot open shared object file: No such file or directory

Your ssh2.so file can't find it. Run this and you'll see what I mean:

ldd /usr/lib64/php/modules/ssh2.so

Try this:

updatedb
locate libssh2.so.1

If found, you may need to create a symlink inside /usr/lib64/ or something.

If that doesn't find it, a quick google search brings up this as a hit for libssh2 on centos5:

http://centos.karan.org/el5/extras/testing/x86_64/RPMS/libssh2-0.18-10.el5.kb.x86_64.rpm

Install that, restart apache, and try it again.

Corey Henderson
  • 7,239
  • 1
  • 39
  • 43
  • Adding the symbolic link returns: `PHP Startup: Invalid library (maybe not a PHP library) 'ssh2.so' in Unknown on line 0` and I have already installed libssh2 – franzlorenzon Feb 28 '13 at 14:29
  • 1
    To resolve this, I installed it: http://stackoverflow.com/questions/8535885/trying-to-install-ssh2-on-php/15138640#15138640 – franzlorenzon Feb 28 '13 at 15:12
-1

Maybe phpseclib, a pure PHP SSH implementation, would work better for you? An example:

<?php
include('Net/SSH2.php');

$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
    exit('Login Failed');
}

echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');
?>
neubert
  • 15,947
  • 24
  • 120
  • 212