问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/8535885/trying-to-install-ssh2-on-php