• lamp php的ssl,ssh支持


    Php支持sslssh扩展:

    准备:可以成功解析php

    1.curl的安装

    [root@localhost~]# cd /usr/local/src/

    [root@localhost~]# wget https://curl.haxx.se/download/curl-7.47.1.tar.gz

    [root@localhost~]# tar zxvf curl-7.47.1.tar.gz

    [root@localhost~]# cd curl-7.47.1

    [root@localhost~]# ./configure --with-ssl --with-libssh2

    出现:configure: error: libSSH2 libs and/or directories were not found where specified!

    [root@localhost ]# yum install libssh2 libssh2-devel

    [root@localhost~]# ./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)

    至此sslssh已经使能了。

    lampphp安装:

    [root@localhost~]# cd php-5.1.14

    [root@localhost~]# ./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

    [root@localhost~]# make

    如果出现 [sapi/cli/php]错误

    执行:

    [root@localhost~]# make ZEND_EXTRA_LIBS='-liconv'

    [root@localhost~]# ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/

    [root@localhost~]# make install

    [root@localhost~]# cp php.ini-production /usr/local/php/etc/php.ini 

    [root@localhost~]# vim /usr/local/php/etc/pnp.ini 

    去掉这行的注解并改成data.timezone = Asia/shanghai

    安装libssh2库与ssh2

    [root@localhost~]# cd /usr/local/src/

    [root@localhost~]# wget http://www.libssh2.org/download/

    [root@localhost~]# wget http://pecl.php.net/package/ssh2

    [root@localhost~]# tar -zxvf libssh2-1.4.2.tar.gz

    [root@localhost~]# cd libssh2-1.4.2

    [root@localhost~]# ./configure --prefix=/usr/local/libssh2

    [root@localhost~]# make && make install

    [root@localhost~]# tar -zxvf ssh2-0.12.tgz

    [root@localhost~]# cd ssh2-0.12

    [root@localhost~]#./configure --prefix=/usr/local/ssh2 --with-ssh2=/usr/local/libssh2 --with-php-config=/usr/local/php/bin/php-config

    [root@localhost~]#make && make install

    [root@localhost~]# cp modules/ssh2.so /usr/lib64/php/modules/

    [root@localhost~]# vim /usr/local/php/etc/php.ini

    添加一行:extension=ssh2.so

    [root@localhost~]# /usr/local/php/sbin/php-fpm -i|grep ssh2

    出现:下图内容则配置成功        

              

    [root@localhost~]# 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));

    ?>

    [root@localhost~]# /usr/local/apache2/bin/apachectl restart

    访问 http://192.168.1.106/3.php

    ssh执行成功!!!

    可能出现的问题:

    php版本与ssh扩展模块版本不匹配,需要更新版本。

  • 相关阅读:
    page指令
    CMD设IP
    JDBC的几种驱动
    Python的闭包使用
    1189. 扫雷游戏
    1287. 递增的三元子序列
    Pip安装使用国内源的两种方法
    Python Classmethod和Staticmethod函数
    Git提交远程仓库
    Git分支管理
  • 原文地址:https://www.cnblogs.com/rohero/p/5295205.html
Copyright © 2020-2023  润新知