Installing PHP-SSH2 (CentOS)

One of the most annoying PHP extensions to install has to be SSH2, not only does it have a few errors when you try to compile it, all these tutorials on the web teach you a really hard way.

This is by far the easiest way to install it, and doesn’t require any editing!

Step 1. Install some requirements (oh and make sure php is installed first)

yum install php-devel php-pear gcc make openssl openssl-devel

Step 2. Download libssh2, compile and install it

mkdir libssh2
cd libssh2
tar xvzf lib*
cd lib*
make install

Step 3. Install the SSH2 module

pecl install ssh2-beta

It will ask for libssh etc locations but just press enter for default, it will try to put the extension in your php.ini automatically but usually fails. So just find your php.ini (usually /etc/php.ini) and place in there

And restart apache, php-cgi, nginx whatever you have running and there you go. php-ssh2 installed. That wasn’t hard, was it?

Ill have a Debian version soon, Debian calls everything wacky names in the repo, so these steps won’t work.

This entry was posted in Uncategorized. Bookmark the permalink.

6 Responses to Installing PHP-SSH2 (CentOS)

  1. Maribeth says:

    AFAICT you’ve ceoevrd all the bases with this answer!

  2. Mark says:

    Thanks Man. You saved me hours!

  3. pThomas says:

    Thanks, nice instructions. A lot simpler then the last time installed ssh2.

  4. Tejas Trivedi says:

    Hi LandofDaniel,

    Today it seems you are god for me. Thanks for your efforts to share. Many Many Thanks,

    And please let me know if you come up with the solution for other linux flavours.


  5. Eli says:


    The final step was giving me an error “configure: error: cannot run C compiled programs” until I typed the two following commands:
    mount -o remount,exec,suid /tmp
    mount -o remount,exec,suid /var/tmp

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>