Friday, May 14, 2010

Installation PHP ssh2 extension on PHP5, Apache2

Here is the way for the installation of ssh2 on php5 and apache2..
Here is the document about the ssh2 php..
Try search around the google..Try doing the compilation..
It is working..So here some guide can be use for the installation

Requirements..Installer file for ssh2 and libssh2
1. "wget http://pecl.php.net/get/ssh2-0.11.0.tgz"
2. "wget http://downloads.sourceforge.net/project/libssh2/old-libssh2-releases/1.1/libssh2-1.1.tar.gz?use_mirror=nchc"

First, install libssh2..
1. tar zxf libssh2-1.1.tar.gz
2. cd libssh2-1.1
3. ./configure
4. make
5. make install

Second, install ssh2..
1. tar zxf ssh2-0.11.0.tgz
2. cd ssh2-0.11.0
3. /usr/local/php/bin/phpize
4. ./configure --with-ssh2 --with-php-config=/usr/local/php/bin/php-config
5. make
6. make install
7. make note on the "Installing shared extensions:" directory path which need in below step
Third, change the php.ini file and restart apache..
1. Edit the php.ini file
vi /usr/local/php/lib/php.ini
2. Add this column to the end of php.ini file..
[ssh2]
extension_dir= ssh2 installed library path
extension=ssh2.so
3. save and exit the php.ini
ctrl + c
:wq
4. restart the apache2
/usr/local/apache2/bin/apachectl restart
# if apache cannot be down..
/usr/local/apache2/bin/apachectl graceful

Check the phpinfo, will see ssh2 is enabled..

3 comments:

Jiby said...

Hi Pohmeng,

Your post looks really good one. I was trying to install SSH2 on my Apache.

In your second part "install ssh2", it says to run ./configure in step4

But I downloaded and untarred ssh2-0.11.0.tgz

I don't see any "configure" script under that. Where are you running that "configure" from ?

Regards,
Jiby

Jiby said...

Pohmeng,

Never mind.it worked now. Was running the ssh2 installer first time. So didn't know that invoking "/usr/local/php/bin/phpize" will do the trick :).

thanks a lot.

jpagedesigns said...

This is an updated guide with updated urls, as of 9/6/2011. I always seem to have issues with libssh2 and openssl, so instead I put together this using the libgcrypt libraries which also allowed for libssh2, and it seems to work flawless for me. hope it helps!

wget ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.10.tar.bz2

1. tar xvjf libgpg-error-1.10.tar.bz2
2. cd libgpg-error-1.10
3. ./configure
4. make
5. make install

wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.5.0.tar.bz2

1. tar xvjf libgcrypt-1.5.0.tar.bz2
2. cd libgcrypt-1.5.0
3. ./configure
4. make
5. make install

wget http://www.libssh2.org/download/libssh2-1.3.0.tar.gz

1. tar zxf libssh2-1.3.0.tar.gz
2. cd libssh2-1.3.0
3. ./configure
4. make
5. make install

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

1. tar zxf ssh2-0.11.0.tgz
2. cd ssh2-0.11.0
3. ./configure
4. make
5. make install

To Finish

Add " extension=ssh2.so " to php ini, restart apache.