Install SSH2 Extension Through PECL (Ubuntu 12+)

I am working on an application that interfaces with remote servers through SSH so of course I need the ssh2 extension installed. I am currently running 5.5 from a previous tutorial, but this should work in the 'traditional' php installed through sudo apt-get install php5-cli.

    sudo apt-get install libssh2-1 libssh2-1-dev
    sudo pecl install ssh2 channel://pecl.php.net/ssh2-0.11.3
    If you read the last bit of text from the previous step, you will notice that the last instruction states: "You should add "extension=ssh2.so" to php.ini", so now you should add that to your php ini files.
    sudo vim /etc/php5/cli/php.ini
    Find the header "Dynamic Extensions" and place extension=ssh2.so directly below as shown here.


    [Don't worry if you don't have that "mongo.so" bit, that's just another extension I have.]
    Now do the same for apache (if you want it there that is)
    sudo vim /etc/php5/apache2/php.ini
    Repeat the previous step (add the .so line), before saving and running the following command.
    sudo service apache2 restart

References

1 comment:

  1. It can be done more easly with:

    sudo apt-get update
    sudo apt-get install -y libssh2-php
    sudo service apache2 reload

    ReplyDelete