How to install ssh2 extension for PHP

Created:

2016-11-16 13:00:53 UTC

Modified:

2017-08-17 17:08:04 UTC

7

Was this article helpful?


Have more questions?

Submit a request

How to install ssh2 extension for PHP

Applicable to:

  • Plesk 12.5 for Linux

Question

How to install ssh extension for PHP?

Answer

For CentOS only

For OS php package:

  1. Install all missing packages:

     # yum install make gcc glibc-devel zlib-devel openssl-devel php-devel
  2. Compile and install libssh2 libraries:

    # wget https://libssh2.org/download/libssh2-1.8.0.tar.gz
    # tar vxzf libssh2-1.8.0.tar.gz
    # cd libssh2-1.8.0/
    # ./configure
    # make
    # make install
  3. Compile and install ssh2 extension:

    # wget https://pecl.php.net/get/ssh2-0.13.tgz
    # tar vxzf ssh2-0.13.tgz
    # cd ssh2-0.13
    # phpize
    # ./configure --with-ssh2
    # make
    # make install
  4. Add extension to PHP:

    # echo "extension=ssh2.so" > /etc/php.d/ssh2.ini
  5. Check that it is working:

    # php -m | grep ssh2
    ssh2

For Plesk php(5.6 as example):

  1. Install all missing packages:

    # yum install make gcc glibc-devel zlib-devel openssl-devel plesk-php56-devel
  2. Compile and install libssh2 libraries(not required if it was previously done):

    # wget https://libssh2.org/download/libssh2-1.8.0.tar.gz
    # tar vxzf libssh2-1.8.0.tar.gz
    # cd libssh2-1.8.0/
    # ./configure
    # make
    # make install
  3. Install ssh2 extension:

    # /opt/plesk/php/5.6/bin/pecl install https://pecl.php.net/get/ssh2-0.13.tgz

    on 'libssh2 prefix? [autodetect] :' leave empty and press enter

  4. Add extension to PHP:

    # echo "extension=ssh2.so" > /opt/plesk/php/5.6/etc/php.d/ssh2.ini
    1. Check that it is working:

      /opt/plesk/php/5.6/bin/php -m| grep ssh2

      ssh2

Note : For Plesk PHP 7.0 it is required to download ssh2-1.0.tgz

Have more questions? Submit a request
Please sign in to leave a comment.