PHP ssh2 Extension Installation detailed _php tutorial

Source: Internet
Author: User
1, there are three servers, the operating system is: 10.1 10.2 11.2 Three different versions, found that 11.2 do not need to install, already have some extensions. If you do not have the installation, it may be convenient to complete the installation via YaST.

Test on the 10.1 server because you need to install LIBSSH before installing ssh2-0.11.0.tgz, so just download it on the website. More than n versions have been downloaded. Not even. is an error while making.

Do not want to find out why, because this situation, may be manifold.

Another server, 10.2, when the trial to libssh2-0.18 time, incredibly successful.

OK, next, should compile ssh2-0.11.0.tgz, hehe, still relatively smooth. actually succeeded.

Now, keep track of your operating procedures so that you don't forget about them later, and you can look at this document again. Oh.

Requires two packages:

ssh2-0.11.0.tgz Download Address: HTTP://PECL.PHP.NET/PACKAGE/SSH2

libssh2-0.18.tar.gz Download Address: http://sourceforge.net/projects/libssh2/files/

Install First, libssh2-0.18.tar.gz

Simple steps:

Tar zxvf libssh2-0.18.tar.gz

CD libssh2-0.18

./configure

Make && make install

Wait a moment.

No accident, it should have succeeded.

Next, install Ssh2-0.11.0.tgz

Tar zxvf ssh2-0.11.0.tgz

CD ssh2-0.11.0

Phpize
./configure--WITH-SSH2
Make
When finished, the ssh2.so file you need is generated in the modules directory in the current directory

Configure it below to let Apache know about it.

This is a good place to copy to your. So file, but this place needs to be aware that there are different versions of so files where the location is a little different.

My is the default path:

/usr/lib/php5/extensions/

CP ssh2.so/usr/lib/php5/extensions/

Also, add a configuration file,

Copy a Ssh2.ini file in the/etc/php5/conf.d/directory

CP Mysql.ini Ssh2.ini

Edit the Ssh2.ini and modify the contents to:

Extension=ssh2.so

Okay, now restart Apapche.

Apache2ctl-k restart

Php-i|grep ssh2 with this command.

No surprises, you will see the relevant information

/etc/php5/conf.d/ssh2.ini,
Registered PHP Streams = php, file, data, HTTP, FTP, HTTPS, FTPs, Ssh2.shell, Ssh2.exec, Ssh2.tunnel, SSH2.SCP, SSH2.S FTP, ZIP, compress.zlib
Ssh2
LIBSSH2 Version = 0.18
Banner = ssh-2.0-libssh2_0.18
PWD =/srv/www/vwokan/wokan2.0/ssh2-0.11.0
_server["PWD"] =/srv/www/vwokan/wokan2.0/ssh2-0.11.0

Hehe, this message indicates that it has been successful.

The next step is to use PHP to execute the SSH2 extension command.

$connection = Ssh2_connect ("172.16.18.252", 22);
if (Ssh2_auth_password ($connection, "root", "123456")) {
echo "Authentication successful!";
} else {
Die (authentication Failed ...);
}

?>

No surprises, you will see "Authentication successful" information.

Oh, I appeared, accident, query a bit. Each time the following prompt appears:

Authentication Failed ...

User name, password, these are not errors ah.

Finally, check the configuration of the native SSH

Vi/etc/ssh/sshd_config

Found in:

Passwordauthentication No

Oh, modified into:

Passwordauthentication Yes

Save, restart SSH

/etc/init.d/sshd restart

Oh, incredibly passed.

http://www.bkjia.com/PHPjc/486196.html www.bkjia.com true http://www.bkjia.com/PHPjc/486196.html techarticle 1, there are three servers, the operating system is: 10.1 10.2 11.2 Three different versions, found that 11.2 do not need to install, already have some extensions. If you do not have the installation, it may be convenient to pass ...

  • 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.