0

When I try to run any php script with my user within shell, I get the following warning:

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

ssh2.so seems to be installed. If I'm using the root user, I don't get this error. From everything I can see, even with my user, the scripts execute successfully regardless of this warning. My php.ini file reads:

extension=ssh2.so

I'm running nginx on RHEL6 (w/o support). I've read through other questions on server fault and have not been able to find a solution that fixes my issue here.

Here's some data:

root $ php -m | grep ssh2
(Nothing returned)

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

root $ ldd /usr/lib64/php/modules/ssh2.so
ldd: /usr/lib64/php/modules/ssh2.so: No such file or directory

myuser $ ldd /usr/lib64/php/modules/ssh2.so
ldd: /usr/lib64/php/modules/ssh2.so: No such file or directory

root $ env
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
USER=root
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
USERNAME=root
PATH=/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
MAIL=/var/spool/mail/root
EDITOR=nano
LANG=en_US.UTF8
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
LOGNAME=root
LESSOPEN=|/usr/bin/lesspipe.sh %s
HISTTIMEFORMAT=[%h %d - %H:%M:%S]
G_BROKEN_FILENAMES=1
_=/bin/env

myuser $ env
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
USER=myuser
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
MAIL=/var/spool/mail/myuser
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/myuser/bin
LANG=en_US.UTF8
HISTCONTROL=ignoredups
SHLVL=1
HOME=/home/myuser
LOGNAME=myuser
LESSOPEN=|/usr/bin/lesspipe.sh %s
HISTTIMEFORMAT=[%h %d - %H:%M:%S]
G_BROKEN_FILENAMES=1
_=/bin/env

This IS NOT a duplicate to Need to run cron jobs in cpanel as a specific user - permission problems.

EDIT (more data):

root $ ls -l /usr/lib64/php/modules/ssh2.so
ls: cannot access /usr/lib64/php/modules/ssh2.so: No such file or directory

myuser $ ls -l /usr/lib64/php/modules/ssh2.so
ls: cannot access /usr/lib64/php/modules/ssh2.so: No such file or directory

EDIT (results to Eamonn Travers answer):

root $ locate ssh2.so
/usr/lib64/libssh2.so.1
/usr/lib64/libssh2.so.1.0.1
root $ ln -s /usr/lib64/libssh2.so.1 /usr/lib64/php/modules/ssh2.so
root $ php -m | grep ssh2
PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'ssh2.so' in Unknown on line 0
root $ ln -s /usr/lib64/libssh2.so.1.0.1 /usr/lib64/php/modules/ssh2.so
root $ php -m | grep ssh2
PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'ssh2.so' in Unknown on line 0
eisaacson
  • 515
  • 3
  • 7
  • 20

2 Answers2

1

Try

locate ssh2.so

It looks as if the library is not there where php is looking for it. locate will find it for you & then you can link it into the directory you need it in.

ln -s /someDirectory/ssh2.so /usr/lib64/php/modules/ssh2.so

Hope this was helpful.

Eamonn Travers
  • 614
  • 4
  • 11
  • Thank you for your answer. This still didn't work. I added my results to my question. – eisaacson Nov 13 '14 at 22:23
  • It appears that ssh2.so is not installed. Have you tried yum install libssh2 libssh2-devel. After that you need to build the library pecl install -f ssh2 & restart the apache. – Eamonn Travers Nov 14 '14 at 05:25
  • `libssh2` was already installed and I have now installed `libssh2-devel`. I'm unclear about the last bit of your instructions but I did restart nginx and am still getting the error. Please note that I do not get this error when executing as the root user. – eisaacson Nov 14 '14 at 16:17
  • You have to compile the library using pecl install -f ssh2 – Eamonn Travers Nov 14 '14 at 18:50
  • `pecl` is not installed on my server. Does that mean this is likely done a different way on this server? If not, can you point me to the right package/repository for `pecl`. `yum` cannot find it. – eisaacson Nov 14 '14 at 18:58
  • Try installing PEAR. yum install pear. It should bring pecl with it. – Eamonn Travers Nov 14 '14 at 19:38
  • `Package 1:php-pear-1.9.4-4.el6.noarch already installed and latest version` – eisaacson Nov 14 '14 at 19:44
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/18661/discussion-between-eamonn-travers-and-eisaacson). – Eamonn Travers Nov 14 '14 at 20:04
  • Thanks. That did it. Thanks again. Actually, here's what I actually did: `$ pear upgrade` `$ yum install gcc php-devel php-pear libssh2 libssh2-devel make` `$ pecl install -f ssh2` It looks like the only thing missing was `php-devel`. Until that, I kept getting `ERROR: phpize failed` If you'll update your answer, I'll accept it. – eisaacson Nov 18 '14 at 15:58
1

I'm not sure what do do for RHEL6 without support. If you were running, CentOS6 and could make use of the EPEL repository this would be the answer:

$ sudo yum install epel-release && sudo install php-pecl-ssh2

$ yum whatprovides "/usr/lib64/php/modules/ssh2.so"
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
 * base: centos.mirror.ndchost.com
 * epel: mirror.sfo12.us.leaseweb.net
 * extras: repos.lax.quadranet.com
 * updates: mirror.web-ster.com
php-pecl-ssh2-0.11.0-7.el6.x86_64 : Bindings for the libssh2 library
Repo        : epel
Matched from:
Filename    : /usr/lib64/php/modules/ssh2.so
84104
  • 12,698
  • 6
  • 43
  • 75