博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PHP7 学习笔记(九)phpsize动态编译openssl扩展 (微信公众平台)
阅读量:7112 次
发布时间:2019-06-28

本文共 2925 字,大约阅读时间需要 9 分钟。

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

一、问题描述:

 使用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/phpizeConfiguring for:PHP Api Version:         20151012Zend Module Api No:      20151012Zend 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 opensslsudo apt-get install libssl-dev

继续编译

makecp ./.libs/openssl.so /home/www/demo/php-7.0.22/ext/openssl/modules/openssl.socp ./.libs/openssl.lai /home/www/demo/php-7.0.22/ext/openssl/modules/openssl.laPATH="$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/modulesIf you ever happen to want to link against installed librariesin a given directory, LIBDIR, you must either use libtool, andspecify 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 formore 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)安装结束

 

转载地址:http://hxghl.baihongyu.com/

你可能感兴趣的文章
使用 Sphinx 撰写技术文档并生成 PDF 总结
查看>>
Fastjson的基本使用方法大全
查看>>
SSH 超时设置
查看>>
webpack 最简打包结果分析
查看>>
NLPIR:数据挖掘深度决定大数据应用价值
查看>>
Flex 布局教程
查看>>
GET和POST两种基本请求方法的区别
查看>>
Webpack4 学习笔记 - 01:webpack的安装和简单配置
查看>>
二)golang工厂模式
查看>>
React 教程:快速上手指南
查看>>
Python 的 heapq 模块源码分析
查看>>
Jitsi快捷安装
查看>>
区块链技术的基本特点
查看>>
阿里云容器服务DaemonSet实践
查看>>
一个游戏拨账系统的数据库结算设计
查看>>
Kafka Network层解析
查看>>
css加载会造成阻塞吗?
查看>>
聊聊storm TridentWindowManager的pendingTriggers
查看>>
React 解决fetch跨域请求时session失效
查看>>
翻译_只需20行代码创造JavaScript模板引擎(二)
查看>>