先吐槽,微信公眾平台授權出問題了,盡然訪問不了
一、問題描述:
使用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)安裝結束