2

Firstly I'm running PHP 5.3.3, CentOS 5.7 (2.6.18-274.3.1.el5xen)

Secondly, I basically have no idea what I'm doing... sorry!

First of all I installed libssh2 from http://www.libssh2.org/. Ran configure, make, make install. Don't really understand all of this stuff, but following online instructions seemed to work.

Then ran

pecl install ssh2

So far so good.

Added the relevant extension line to php.ini, as instructed. Restarted apache:

service httpd restart

All good.

But then can't find any reference to ssh in phpInfo().

Tried

php -m | grep ssh2

and got the following error:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: undefined symbol: libssh2_sftp_readdir_ex in Unknown on line 0

What have I done wrong/missed out, and how can I fix it?

15
  • Did you add the line to the correct php.ini file?
    – richsage
    Commented Dec 16, 2011 at 14:57
  • FYI uk3.php.net/manual/en/ssh2.configuration.php Commented Dec 16, 2011 at 15:04
  • 1
    I did rich. If I hadn't it wouldn't be trying to load the extension and there'd be no error possible! :)
    – Codemonkey
    Commented Dec 16, 2011 at 15:07
  • Where do I find the ssh2.c file it mentions @liquorvicar? When I unpack the tar.gz file there's a /test/ssh2.c and /example/ssh2.c? I checked again after "configure" and "make" and no new copies of the file appeared anywhere. Neither of those files sound right from the directory names, and they don't contain the lines specified in the link you gave? :(
    – Codemonkey
    Commented Dec 16, 2011 at 15:13
  • @Codemonkey I'm no expert on the inner workings of PECL as anything I've ever had to install has worked out of the box but my guess would be PECL comes with an ssh2.c file. Maybe someone who knows more about PECL can clarify if that's true and if so how you download the PECL module and change the file before installing. Commented Dec 16, 2011 at 15:18

1 Answer 1

13

I had a similar problem with CentOs 6.3, and I followed this guide a bit differently.

1) Install needed packages:

yum install automake make php-devel libtool openssl-devel gcc++ gcc

2) Change directory (/usr/lib/php if you have a 32bit OS):

cd /usr/lib64/php

3) Download the source (latest as of 2013/02/28, check latest here):

wget http://pecl.php.net/get/ssh2-0.12.tgz

4) Create a build directory (I don't like mess in my system) and untar the package:

mkdir build-dir
mv ssh2-0.12.tgz build-dir
cd build-dir
tar xzvf ssh2-0.12.tgz

5) Prepare the compile step and compile:

phpize
./configure –with-ssh2
make

6) Copy the module in the system (/usr/lib/php/modules/ssh2.so if you have a 32bit OS):

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

7) Change configuration and add this line to /etc/php.d/ssh2.ini (although I didn't need to do this on my setup, maybe because I had already done this in the past):

extension=ssh2.so

8) If you want you can delete the build directory:

cd ../../
rm -f build-dir

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.