Linux system Installation SSH2 expansion steps detailed

Source: Internet
Author: User

Today there is nothing to say to everyone about Linux installation SSH2 expansion, want to install under the WinDOS but PHP expansion can not find, tears running ...
So I can only do experiments in Linux, but all the same,,,,

Download Address

wget http://www.libssh2.org/download/libssh2-1.4.2.tar.gz
wget http://pecl.php.net/get/ssh2-0.12.tgz

Install LIBSSH2 before installing SS2

# TAR-ZXVF Libssh2-1.4.2.tar.gz
# CD libssh2-1.4.2
#./configure--PREFIX=/USR/LOCAL/LIBSSH2
# Make && make install

For the above installation LIBSSH2, you need to remember LIBSSH2 's installation directory, because it will be used when installing SSH2.

# TAR-ZXVF Ssh2-0.12.tgz
# CD ssh2-0.12
# phpize
#./configure--prefix=/usr/local/ssh2--with-ssh2=/usr/local/libssh2
# make

SSH installation

# TAR-ZXVF Ssh2-0.12.tgz
# CD ssh2-0.12
# phpize
#./configure--prefix=/usr/local/ssh2--with-ssh2=/usr/local/libssh2--with-php-config=/usr/local/php/bin/ Php-config
# Make && make install

SSH2 expands in/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/directory after Setup completes
Modify php.ini file Join

Extension=ssh2.so

Ah haha join expansion success

<?php
$user = "root";//remote User name
$pass = "123456";//Remote password
$connection =ssh2_connect (' 192.168.1.46 ', 22);
Ssh2_auth_password ($connection, $user, $pass);
$cmd = "ps aux";//Command
$ret =ssh2_exec ($connection, $cmd);
Stream_set_blocking ($ret, true);
Echo (Stream_get_contents ($ret));
Print_r (Phpinfo ());
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.