首页 > 代码库 > Linux环境安装ssh2扩展模块

Linux环境安装ssh2扩展模块

环境:Linux环境(Centos or RedHat)

1、确认环境已安装php-5

# rpm -qa|grep php-5
php-5.3.3-48.el6_8.x86_64

技术分享

2、安装ssh2所依赖的rpm包如下图灰色部分显示,安装顺序可以按照灰色部分显示安装的时间顺序进行安装:

rpm命令:

查询命令:rpm -qa|grep xxx

安装命令:rpm -ivh xxx.rpm

删除已安装的rpm:rpm -e xxx                (xxx:要删除的已安装的rpm名)

注明:rpm包的版本要根据Linux系统原有包版本去选择,在安装rpm时,如果遇到安装错误,提示缺少依赖,请去检查rpm版本是否符合或去查看所依赖的包是否已安装。

技术分享

技术分享

安装所需要的rpm包如下图所示:

libssh2-devel-1.4.2-2.el6_7.1.x86_64     
openssl-devel-1.0.1e-48.el6_8.1.x86_64   
krb5-devel-1.10.3-57.el6.x86_64          
zlib-devel-1.2.3-29.el6.x86_64           
libcom_err-devel-1.41.12-22.el6.x86_64   
libselinux-devel-2.0.94-7.el6.x86_64     
libsepol-devel-2.0.41-4.el6.x86_64       
keyutils-libs-devel-1.4-5.el6.x86_64     
php-devel-5.3.3-48.el6_8.x86_64          
php-pear-1.9.4-5.el6.noarch              
automake-1.11.1-4.el6.noarch             
autoconf-2.63-5.1.el6.noarch 

技术分享技术分享

 

3、安装ssh2-0.13.tgz

首先下载ssh2的源码包ssh2-0.13.tgz(版本不同可能导致安装失败)

# tar -xvf  ssh2-0.13.tgz

# cd ssh2-0.13
# phpize
# ./configure --prefix=/usr/local/ssh2
# make
# make install

4、ssh2扩展在php.ini文件中追加

# vi /etc/php.ini  
extension=ssh2.so
# cat /etc/php.ini | grep extension=ss
extension=ssh2.so

5、ssh2安装成功确认

# php -m | grep ssh2
ssh2

# php -i | grep ssh2
Registered PHP Streams => https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp, phar, zip  
libSSH Version => libssh2/1.4.2
PHP Warning:  Unknown: It is not safe to rely on the system‘s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘UTC‘ for ‘GMT/0.0/no DST‘ instead in Unknown on line 0
ssh2
libssh2 version => 1.4.2
banner => SSH-2.0-libssh2_1.4.2

Linux环境安装ssh2扩展模块