centos yum apm

yum -y install mysql mysql-server mysql-devel php

service mysqld startmysql

mysqladmin -u root password 123456sql

use test;apache

create table ip (ip varchar(20),dk varchar(20),name varchar(20));vim

insert into ip values('192.168.1.1','20','test1');ssh

yum -y install httpdide

yum -y install php php-devel  #phpize安裝須要php-devel測試

yum search php (搜索php相關的組件) spa

yum -y install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc .net

yum install libssh2 libssh2-devel

wget http://pecl.php.net/get/ssh2-0.11.3.tgz

tar zxf ssh2-0.11.3.tgz
cd ssh2-0.11.3
phpize
./configure --with-ssh2 && make
編譯完成後,在當前目錄下的modules目錄中生成ssh2.so文件,將這個文件複製到php的modules目錄中(若是不知道這個目錄的位置,可根據php.ini中的extension_dir定義查看)。
 
cp ssh2.so /usr/lib64/php/modules/
 
編輯/etc/php.ini 加入代碼:
vim /etc/php.ini
extension=ssh2.so
 
重啓apache服務
/etc/init.d/httpd restart
 
查看是否加載了ssh2
[root@localhost ~]# php -m | grep ssh2
ssh2
經過如下php代碼測試:
<?php
$connection = ssh2_connect("192.168.209.250",22);
if (ssh2_auth_password($connection,"root","redhat"))
{
      echo "Authentication Successful! ";
}
else
{
      die("Authentication Failed...");
}
?>
相關文章
相關標籤/搜索