CentOS 6.4 - Install SSH2 extension for PHP

    Install the necessary packages before you can build/install ssh2 extension
    yum install gcc php-devel php-pear libssh2 libssh2-devel make
    Install the extension, (hit enter for autodetect when it prompts you)
    pecl install -f ssh2
    Once the install is completed, you just have to tell PHP to load the extension when it boots.
    echo extension=ssh2.so > /etc/php.d/ssh2.ini
    
    Restart your webserver and test to see if the changes took effect.
    service httpd restart
    You can check it installed with the following command
    php -m | grep ssh2

References

16 comments:

  1. When I ran "pecl install -f ssh2" it gave me following error:
    "PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 3200 bytes) in /usr/share/pear/pearcmd.php on line 66
    "

    Should I change the value of pearcmd.php?

    ReplyDelete
    Replies
    1. I doesnt got this i installed all and succs :)

      Delete
    2. Thank you. It's good to know that I probably didn't leave something out.

      Delete
  2. I have not come across this problem. Did you manage to find out what was wrong? Has anyone else had the same problem? If so please leave a comment.

    ReplyDelete
  3. Good tutorial!!!! Tout a marché comme sur des roulettes.

    ReplyDelete
  4. Worked for me Centos 6.4 x64. Many Thanks

    ReplyDelete
  5. When I run "pecl install -f ssh2", I've got this message:

    No releases available for package "pecl.php.net/ssh2"
    install failed

    Do you know what could be happening?

    ReplyDelete
  6. worked on centos 6.4 x64! Thanx!

    ReplyDelete
  7. This line (touch /etc/php.d/ssh2.ini) gives the error "touch: cannot touch `/etc/php.d/ssh2.ini': No such file or directory" on centOS 6.4 x64 for me. However, if I skip that and check it (php -m | grep ssh2) it comes back with "ssh2".

    ReplyDelete
    Replies
    1. That touch command was redundant anyways as the echo command should create the file if it does not exist already and because there is a single > instead of two >>, then it replaces the file. I don't know why you got that error message. Are you not running as a subuser instead of root? Glad it's working anyway.

      Delete
  8. Hi,

    When i try to test if its installed successfully by

    php -m | grep ssh2

    I get

    PHP Syntax Error: Unexpected '(' in /etc/php.d/ssh2.ini on line 37

    What could be reason for this? Thanks for looking into this.

    ReplyDelete
  9. i use centos 7, it's work. thank for the guide.

    ReplyDelete
  10. Thanks!!!!!!!!!!!!I need it!!!!!!!!!!!!
    Centos 6.7.Work!

    ReplyDelete
  11. This helped me a lot on Centos 6.8 Thanks!

    ReplyDelete
  12. This helped me on Centos 6.8 Thanks!

    ReplyDelete