How to install LibSSH2 on a CentOS 5 system

Posted on 01/05/10, in CentOS, PHP, by kevin

Libssh2 is a C library implementing the SSH2 protocol for PHP. Here’s how to get it installed on a CentOS system running PHP 5.1.6.

First step is to install some dependencies.

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

Next, let’s download the latest release of libssh2 (1.2.2 at time of writing), unpack and install

# cd /tmp
# wget http://www.libssh2.org/download/libssh2-1.2.2.tar.gz
# tar -zxf libssh2-1.2.2.tar.gz
# cd libssh2-1.2.2
# ./configure
# make all install
# cd ..
# rm -rf libssh2-1.2.2

Now we need to install the PHP bindings.

# cd /usr/lib/php (for x64 systems use /usr/lib64/php)
# wget http://pecl.php.net/get/ssh2-0.11.0.tgz
# tar -zxf ssh2-0.11.0.tgz
# cd ssh2-0.11.0
# phpize && ./configure –with-ssh2 && make
# cd modules
# mv ssh2.so /usr/lib/php/modules/ssh2.so
# cd /usr/lib/php
# rm -rf ssh2-0.11.0
# rm -f ssh2-0.11.0.tgz

Update the PHP ini file and add the ssh2.so extension like this.

# vi /etc/php.ini
extension_dir = “/usr/lib/php/modules”
extension = ssh2.so

Now restart apache and everything should be installed. You can test it my looking at the out put of # php -m that will list all of the installed modules.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogosphere News
  • DZone
  • email
  • LinkedIn
  • MySpace
  • PDF
  • RSS
  • StumbleUpon
  • Twitter

6 Responses to “How to install LibSSH2 on a CentOS 5 system”


Force Magic
2-18-2010

Really helpful! Thx Kevin!


Jason Launer
3-11-2010

Much appreciated :)


UxperienLab
6-18-2010

I have a problem!!

When I do this:
phpize && ./configure –with-ssh2 && make

I have an error:
checking build system type… Invalid configuration `–with-ssh2′: machine `–with’ not recognized
configure: error: /bin/sh ./config.sub –with-ssh2 failed

:(

Can you help me please!!!


kevin
6-19-2010

Are you typing it correctly? the argument is a double hyphen, with, single hyphen, ssh2.

Also what version of CentOS are you running?


oscar
6-30-2010

Hey Kevin, I’m getting the same error:

checking build system type… Invalid configuration `.with-ssh2′: machine `.with’ not recognized
configure: error: /bin/sh ./config.sub .with-ssh2 failed

Can you help me please?


xfr
7-15-2010

-with-ssh2 has a hyphen in front of it. Not a dot. Why donw you just copy and paste.

as a side note –
it would be more elegant to put the line “extension = ssh2.so” into a separate file under /etc/php.d/ – for instance /etc/php.d/ssh2.ini
Then you do not need to modify the php.ini at all if the extension_dir is already there (and it usually is).

Leave a Reply