lamp php的ssl,ssh支持
Posted Rohero
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lamp php的ssl,ssh支持相关的知识,希望对你有一定的参考价值。
php支持ssl,ssh扩展:
准备:可以成功解析php
1.curl的安装
[[email protected]~]# cd /usr/local/src/
[[email protected]~]# wget https://curl.haxx.se/download/curl-7.47.1.tar.gz
[[email protected]~]# tar zxvf curl-7.47.1.tar.gz
[[email protected]~]# cd curl-7.47.1
[[email protected]~]# ./configure --with-ssl --with-libssh2
出现:configure: error: libSSH2 libs and/or directories were not found where specified!
[[email protected] ]# yum install libssh2 libssh2-devel
[[email protected]~]# ./configure --with-ssl --with-libssh2
curl version: 7.47.1
Host setup: x86_64-pc-linux-gnu
Install prefix: /usr/local
Compiler: gcc
SSL support: enabled (OpenSSL)
SSH support: enabled (libSSH2)
至此ssl,ssh已经使能了。
lamp的php安装:
[[email protected]~]# cd php-5.1.14
[[email protected]~]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6 --with-curl --with-openssl --with-zlib-dir --enable-ftp
[[email protected]~]# make
如果出现 [sapi/cli/php]错误
执行:
[[email protected]~]# make ZEND_EXTRA_LIBS=‘-liconv‘
[[email protected]~]# ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/
[[email protected]~]# make install
[[email protected]~]# cp php.ini-production /usr/local/php/etc/php.ini
[[email protected]~]# vim /usr/local/php/etc/pnp.ini
去掉这行的注解并改成data.timezone = Asia/shanghai
安装libssh2库与ssh2
[[email protected]~]# cd /usr/local/src/
[[email protected]~]# wget http://www.libssh2.org/download/
[[email protected]~]# wget http://pecl.php.net/package/ssh2
[[email protected]~]# tar -zxvf libssh2-1.4.2.tar.gz
[[email protected]~]# cd libssh2-1.4.2
[[email protected]~]# ./configure --prefix=/usr/local/libssh2
[[email protected]~]# make && make install
[[email protected]~]# tar -zxvf ssh2-0.12.tgz
[[email protected]~]# cd ssh2-0.12
[[email protected]~]#./configure --prefix=/usr/local/ssh2 --with-ssh2=/usr/local/libssh2 --with-php-config=/usr/local/php/bin/php-config
[[email protected]~]#make && make install
[[email protected]~]# cp modules/ssh2.so /usr/lib64/php/modules/
[[email protected]~]# vim /usr/local/php/etc/php.ini
添加一行:extension=ssh2.so
[[email protected]~]# /usr/local/php/sbin/php-fpm -i|grep ssh2
出现:下图内容则配置成功
[[email protected]~]# vim /data/www/3.php
<?php
$user="root";
$pass="li";
$connection=ssh2_connect(‘192.168.1.111‘,22);
ssh2_auth_password($connection,$user,$pass);
$cmd="ls";
$ret=ssh2_exec($connection,$cmd);
stream_set_blocking($ret, true);
echo (stream_get_contents($ret));
?>
[[email protected]~]# /usr/local/apache2/bin/apachectl restart
即ssh执行成功!!!
可能出现的问题:
php版本与ssh扩展模块版本不匹配,需要更新版本。
以上是关于lamp php的ssl,ssh支持的主要内容,如果未能解决你的问题,请参考以下文章