Welcome to Centmin Mod Community
Register Now

PHP-FPM Install PHP extension ssh2

Discussion in 'Centmin Mod Insights' started by Steve Tozer, Jul 30, 2014.

  1. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    1:50 AM
    1.91
    10.0.19
    Hello,
    Im needing to install the php extension ssh2. Just wondering the best way to do this while using centmin

    Thanks
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    10:50 AM
    Nginx 1.13.x
    MariaDB 5.5
    The Centmin Mod Insights forum Centmin Mod Insights delves deeper into customising or extending your Centmin Mod installations yourself.

    Examples of adding additional PHP extensions include:
    So for PHP ssh2 extension info is at PHP: SSH2 - Manual and install instructions at PHP: Installation - Manual

    So for Centmin Mod, the SSH commands and steps would be. The /svr-setup is where most of all Centmin Mod source downloaded files etc are located.

    Code:
    yum -q -y install libssh2 libssh2-devel
    cd /svr-setup
    wget http://pecl.php.net/get/ssh2-0.12.tgz
    tar xvzf ssh2-0.12.tgz
    cd ssh2-0.12
    phpize
    ./configure --with-ssh2 --with-php-config=/usr/local/bin/php-config
    make
    make install
    
    Then setup the ssh2.ini file to load the ssh2.so extension
    Code:
    CONFIGSCANDIR='/etc/centminmod/php.d'
    touch ${CONFIGSCANDIR}/ssh2.ini
    echo "extension=ssh2.so" > ${CONFIGSCANDIR}/ssh2.ini
    service php-fpm restart
    
    the option --with-php-config=/usr/local/bin/php-config makes it so the ssh2.so file is automatically moved and placed in the right php extension directory when make install command is run

    Code:
    make install
    Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20131227/
    Then typing command below to list all PHP compiled and loaded PHP Extensions and look for ssh2
    Code:
    php -m
    
    Code:
    php -m
    [PHP Modules]
    bcmath
    bz2
    calendar
    Core
    ctype
    curl
    date
    dom
    enchant
    ereg
    exif
    filter
    ftp
    gd
    gettext
    gmp
    hash
    iconv
    imap
    intl
    json
    libxml
    mbstring
    mcrypt
    mhash
    mysql
    mysqli
    mysqlnd
    openssl
    pcntl
    pcre
    PDO
    pdo_mysql
    pdo_sqlite
    Phar
    posix
    pspell
    readline
    Reflection
    session
    shmop
    SimpleXML
    soap
    sockets
    SPL
    sqlite3
    ssh2
    standard
    sysvmsg
    sysvsem
    sysvshm
    tidy
    tokenizer
    xml
    xmlreader
    xmlrpc
    xmlwriter
    Zend OPcache
    zip
    zlib
    
    [Zend Modules]
    Zend OPcache
    Typing command below will output all PHP's accompanying custom PHP extension .ini files where custom PHP extensions are loaded i.e.
    Code:
    php --ini
    
    Code:
    Configuration File (php.ini) Path: /usr/local/lib
    Loaded Configuration File:         /usr/local/lib/php.ini
    Scan for additional .ini files in: /etc/centminmod/php.d
    Additional .ini files parsed:      /etc/centminmod/php.d/ssh2.ini,
    /etc/centminmod/php.d/zendopcache.ini
    
    Finally to see the specifics from PHP via command
    Code:
    php --ri ssh2
    
    Code:
    ssh2
    
    SSH2 support => enabled
    extension version => 0.12
    libssh2 version => 1.4.2
    banner => SSH-2.0-libssh2_1.4.2
    
    This same info would be seen if you loaded up a PHPINFO page and scrolled to ssh2 section.
     
    Last edited: Sep 2, 2015
    • Like Like x 3
  3. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    1:50 AM
    1.91
    10.0.19
    Thank you (y) @eva2000

    If I upgrade the PHP version will this get reinstalled at the same time
     
  4. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    10:50 AM
    Nginx 1.13.x
    MariaDB 5.5
    You're welcome :)

    For minor PHP versions, if the /etc/centminmod/php.d/ssh2.ini still exists, then no need to reinstall ssh2 as outlined above. But for major PHP versions, I'd re-run the above steps again to recompile ssh2 PHP extension.

    minor PHP = 5.4.30 to 5.4.31
    major PHP = 5.4.31 to 5.5.15 etc
     
    • Like Like x 2
  5. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    1:50 AM
    1.91
    10.0.19
    Thanks again :D
     
  6. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    10:50 AM
    Nginx 1.13.x
    MariaDB 5.5
    Actually how easy is it to turn all those commands into a shell script to re-run when you want :)

    Just need to add a few extra lines i.e. make clean to remove the old installed version files

    save contents into ssh2.sh
    Code:
    #!/bin/bash
    cd /svr-setup
    wget http://pecl.php.net/get/ssh2-0.12.tgz
    tar xvzf ssh2-0.12.tgz
    cd ssh2-0.12
    make clean
    phpize
    ./configure --with-ssh2 --with-php-config=/usr/local/bin/php-config
    make
    make install
    
    CONFIGSCANDIR='/etc/centminmod/php.d'
    touch ${CONFIGSCANDIR}/ssh2.ini
    echo "extension=ssh2.so" > ${CONFIGSCANDIR}/ssh2.ini
    service php-fpm restart
    
    To run the ssh2.sh script
    Code:
    chmod +x ssh2.sh
    ./ssh2.sh
     
    • Like Like x 1
  7. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    1:50 AM
    1.91
    10.0.19
    Good point

    After
    Code:
    cd /svr-setup
    Wouldnt it be better to run
    Code:
    rm -f ssh2-0.12.tgz
    rm -rf ssh2-0.12
    Then the rest of the script just to check the files/directories are not there already
    So it re-downloads a new copy.
     
  8. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    10:50 AM
    Nginx 1.13.x
    MariaDB 5.5
    Yeah you could.. I was of the mindset for just the compiled and installed files that need wiping (make clean). It should be okay to have the remain. Up to you :)

    so revised on would be

    Code:
    #!/bin/bash
    cd /svr-setup
    cd ssh2-0.12
    make clean
    
    cd /svr-setup
    rm -rf ssh2-0.12.tgz
    rm -rf ssh2-0.12
    wget http://pecl.php.net/get/ssh2-0.12.tgz
    tar xvzf ssh2-0.12.tgz
    cd ssh2-0.12
    make clean
    phpize
    ./configure --with-ssh2 --with-php-config=/usr/local/bin/php-config
    make
    make install
    
    CONFIGSCANDIR='/etc/centminmod/php.d'
    touch ${CONFIGSCANDIR}/ssh2.ini
    echo "extension=ssh2.so" > ${CONFIGSCANDIR}/ssh2.ini
    service php-fpm restart
     
    • Like Like x 1
  9. sepulchre

    sepulchre Member

    90
    15
    8
    Dec 22, 2014
    Ratings:
    +15
    Local Time:
    2:50 AM
    Thank you, I successfully addes ssh2 to my server.
    Maybe it would be great if you could add the ssh2 extension to the next branches, so we have it by default.

    For Xenforo users, SneakyDave created this wonderful working backup add-on.
    [SolidMean] ForumBackup | XenForo Community
    Just configure the cron and you get your daily backups (or whatever you set)

    And this add-on (which I haven't tested yet) moves the backups via ftp to a server, so your stuff is backed up somewhere else.
    [SolidMean] ForumBackup SFTP Transfer | XenForo Community
    You don't need scripts or knowledge, just Xenforo and those 2 add-ons. But the SFTP transfer add-on needs the ssh2 extension to be installed. So I thought maybe you could make that default to the Centmin Mod. But of course not everyone would benefit from it, so you know the best about it.

    I just wanted to mention this and thank you sooo much for Centmin Mod!!!
     
    • Like Like x 1
  10. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    10:50 AM
    Nginx 1.13.x
    MariaDB 5.5
    According to PECL :: Package :: ssh2 and @SneakyDave the ssh2 package is pretty old. So why not install from ssh2 git master branch ? :D

    edit: oh github hosted repo php/pecl-networking-ssh2 · GitHub instead of https://git.php.net/repository/pecl/networking/ssh2.git

    Code:
    cd /svr-setup/
    yum -q -y install libssh2 libssh2-devel
    git clone https://git.php.net/repository/pecl/networking/ssh2.git ssh2-master
    cd ssh2-master
    phpize
    ./configure --with-ssh2 --with-php-config=/usr/local/bin/php-config
    make
    make install
    CONFIGSCANDIR='/etc/centminmod/php.d'
    touch ${CONFIGSCANDIR}/ssh2.ini
    echo "extension=ssh2.so" > ${CONFIGSCANDIR}/ssh2.ini
    service php-fpm restart
    
    Code:
     php --ri ssh2   
    
    ssh2
    
    SSH2 support => enabled
    extension version => 0.12+dev
    libssh2 version => 1.4.3
    banner => SSH-2.0-libssh2_1.4.3
    ssh2 master last commit was March 28, 2014 versus ssh2 0.12 tag last commit was October 17, 2012

    upload_2015-5-21_0-54-33.png
     
    Last edited: Nov 2, 2015
    • Like Like x 1
  11. Oxide

    Oxide Active Member

    504
    29
    28
    Mar 19, 2015
    Ratings:
    +54
    Local Time:
    10:50 AM
    Would this work for the latest centmin version?
     
  12. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    10:50 AM
    Nginx 1.13.x
    MariaDB 5.5
    Yup :)
     
  13. Sunka

    Sunka Active Member

    917
    240
    43
    Oct 31, 2015
    Rijeka, Croatia
    Ratings:
    +388
    Local Time:
    2:50 AM
    Nginx 1.13.3
    MariaDB 10.1.24

    For new link with new version (2015-07-15), should it be:

    Code:
    cd /svr-setup/
    yum -q -y install libssh2 libssh2-devel
    git clone https://git.php.net/repository/pecl/networking/ssh2.git ssh2-master
    cd ssh2-master
    phpize
    ./configure --with-ssh2 --with-php-config=/usr/local/bin/php-config
    make
    make install
    CONFIGSCANDIR='/etc/centminmod/php.d'
    touch ${CONFIGSCANDIR}/ssh2.ini
    echo "extension=ssh2.so" > ${CONFIGSCANDIR}/ssh2.ini
    service php-fpm restart
    
     
    Last edited: Nov 2, 2015
    • Informative Informative x 1
  14. Sunka

    Sunka Active Member

    917
    240
    43
    Oct 31, 2015
    Rijeka, Croatia
    Ratings:
    +388
    Local Time:
    2:50 AM
    Nginx 1.13.3
    MariaDB 10.1.24
    • Like Like x 1
  15. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    10:50 AM
    Nginx 1.13.x
    MariaDB 5.5
    nice catch
     
    • Agree Agree x 1
  16. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    10:50 AM
    Nginx 1.13.x
    MariaDB 5.5
    for php 7 supported ssh2 branch Sean-Der/pecl-networking-ssh2 at php7 · GitHub
    Code:
    cd /svr-setup/
    yum -q -y install libssh2 libssh2-devel
    rm -rf ssh2-php7
    git clone -b php7 https://github.com/Sean-Der/pecl-networking-ssh2.git ssh2-php7
    cd ssh2-php7
    phpize
    ./configure --with-ssh2 --with-php-config=/usr/local/bin/php-config
    make
    make install
    CONFIGSCANDIR='/etc/centminmod/php.d'
    touch ${CONFIGSCANDIR}/ssh2.ini
    echo "extension=ssh2.so" > ${CONFIGSCANDIR}/ssh2.ini
    service php-fpm restart
     
    Last edited: Dec 5, 2015
    • Like Like x 1
  17. Sunka

    Sunka Active Member

    917
    240
    43
    Oct 31, 2015
    Rijeka, Croatia
    Ratings:
    +388
    Local Time:
    2:50 AM
    Nginx 1.13.3
    MariaDB 10.1.24
    Code:
    Starting php-fpm  done
    [root@tvor-ocean ~]# cd /svr-setup/
    You have new mail in /var/spool/mail/root
    [root@tvor-ocean svr-setup]# yum -q -y install libssh2 libssh2-devel
    Package libssh2-1.4.3-8.el7.x86_64 already installed and latest version
    Package libssh2-devel-1.4.3-8.el7.x86_64 already installed and latest version
    [root@tvor-ocean svr-setup]# rm -rf ssh2-php7
    [root@tvor-ocean svr-setup]# git -b php7 clone https://github.com/Sean-Der/pecl-networking-ssh2.git ssh2-php7
    Unknown option: -b
    usage: git [--version] [--help] [-c name=value]
               [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
               [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
               [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
               <command> [<args>]
    [root@tvor-ocean svr-setup]# cd ssh2-php7
    -bash: cd: ssh2-php7: No such file or directory
    [root@tvor-ocean svr-setup]# phpize
    Cannot find config.m4.
    Make sure that you run '/usr/local/bin/phpize' in the top level source directory of the module
     
  18. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    10:50 AM
    Nginx 1.13.x
    MariaDB 5.5
    corrected the git clone command it had -b php7 in wrong order
     
    • Like Like x 1
  19. Oxide

    Oxide Active Member

    504
    29
    28
    Mar 19, 2015
    Ratings:
    +54
    Local Time:
    10:50 AM
    whats the latest php version supported by centmin? i want to upgrade, idk why tho

    php 7 , would it break anything upgrading to it? scared lel

    edit: updating..

    PHP Upgrade - Would you like to continue? [y/n] y
    ----------------------------------------------------------------
    Install which version of PHP? (version i.e. 5.4.45, 7.0.0, NGDEBUG)
    PHP 7.0.0 is experimental in alpha status and may have broken PHP extensions.
    NGDEBUG is PHP 7.0.0 minus incompatible PHP extensions
    ----------------------------------------------------------------
    Enter PHP Version number you want to upgrade/downgrade to: 7.0.0
    ----------------------------------------------------------------
    Want to update to latest php-fpm.conf ? (overwrites will auto backup existing php-fpm.conf)
    existing php.ini will be backed up at /usr/local/lib/php.ini-oldversion_041215-232043
    existing php-fpm.conf will be backed up at /usr/local/etc/php-fpm.conf-oldversion_041215-232043
    ----------------------------------------------------------------
    Update & overwrite your existing php-fpm.conf [y/n]: y
    ----------------------------------------------------------------
    Downloading PHP 7.0 from https://git.php.net/repository/php-src.git
    Initialized empty Git repository in /svr-setup/php-7.0.0/.git/
     
  20. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    10:50 AM
    Nginx 1.13.x
    MariaDB 5.5