zoukankan      html  css  js  c++  java
  • PHP7 学习笔记(九)phpsize动态编译openssl扩展 (微信公众平台)

    先吐槽,微信公众平台授权出问题了,尽然访问不了

    一、问题描述:

     使用PHP中的库函数file_get_contents时出现Unable to find the wrapper "https"错误解决

      出现这个错误的原因很简单,因为你php配置出了问题,先说一下为什么会出现这个问题,原因是你的URL地址的前缀是https;在URL前加https前缀表明是用SSL加密的。 你的电脑与服务器之间收发的信息传输将更加安全。Web服务器启用SSL需要获得一个服务器证书并将该证书与要使用SSL的服务器绑定。

      http和https使用的是完全不同的连接方式,用的端口也不一样,前者是80,后者是443。http的连接很简单,是无状态的。HTTPS协议是由SSL+HTTP协议构建的可进行加密传输、身份认证的网络协议要比http协议安全。读完这段话你也应该知道原因了。因为你的php配置中的加密模块并没有打开。

    二、问题解决方案

    (1)重新编译openssl扩展

    (2)php7 源码目录路径:/home/www/demo/php-7.0.22/

    (3)进入openssl的扩展目录:/home/www/demo/php-7.0.22/ext/openssl

    (4)运行phpize生成编译的配置文件,可能会出现以下错误

    Cannot find config.m4. 
    Make sure that you run '/usr/bin/phpize' in the top level source directory of the module

    解决办法:在当前目录复制一份编译需要的文件,执行命令: cp ./config0.m4 ./config.m4  即可,继续以上的操作,生成通过

    www@tinywan:~/demo/php-7.0.22/ext/openssl$ /opt/php7.0.22/bin/phpize
    Configuring for:
    PHP Api Version:         20151012
    Zend Module Api No:      20151012
    Zend Extension Api No:   320151012

    (5)检测编译文件是否通过

    sudo ./configure --with-openssl --with-php-config=/opt/php7.0.22/bin/php-config

    (6)开始编译

    遇到以下错误

    /usr/include/openssl/conf.h:132:7: note: expected 'struct lhash_st_CONF_VALUE *' but argument is of type 'int *' make: *** [ext/openssl/openssl.lo] Error 1

    注意:我踩的一个坑,安装的是php7.0.22的版本,结果我下载的7.0.9的版本,这样子也会提示以下错误信息

    Make sure that you run '/opt/php7.0.22/bin/phpize' in the top level source directory of the module

    安装以下扩展

    sudo apt-get install openssl
    sudo apt-get install libssl-dev

    继续编译

    make
    
    cp ./.libs/openssl.so /home/www/demo/php-7.0.22/ext/openssl/modules/openssl.so
    cp ./.libs/openssl.lai /home/www/demo/php-7.0.22/ext/openssl/modules/openssl.la
    PATH="$PATH:/sbin" ldconfig -n /home/www/demo/php-7.0.22/ext/openssl/modules
    ----------------------------------------------------------------------
    Libraries have been installed in:
       /home/www/demo/php-7.0.22/ext/openssl/modules
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    ----------------------------------------------------------------------
    
    Build complete.
    Don't forget to run 'make test'.

    安装

    www@ubuntu1:~/demo/php-7.0.22/ext/openssl$ sudo make install
    [sudo] password for www: 
    Installing shared extensions:     /opt/php7.0.22/lib/php/extensions/no-debug-non-zts-20151012/

    (7)修改配置php.ini文件:sudo vim /opt/php7.0.22/etc/php.ini 添加以下代码

    extension=/opt/php7.0.22/lib/php/extensions/no-debug-non-zts-20151012/openssl.so

    (8)重启服务器,查看扩展是否安装成功

    (9)安装结束

     

  • 相关阅读:
    二叉搜索树的后序遍历序列
    验证二叉搜索树
    合并二叉树
    工龄计算方案
    hadoop集群中动态添加节点
    java知识点
    Hadoop经典案例(排序&Join&topk&小文件合并)
    mysql学习
    大数据开发面试
    我保存的网址
  • 原文地址:https://www.cnblogs.com/tinywan/p/7832066.html
Copyright © 2011-2022 走看看