在centos 6.2的系統里面的curl支持的https是nss版本的,而不是openssl的,所以在php使用curl訪問https的時候會報Unable to load client key -8178的錯誤,在google group里面找到了靈感,也是curl和https的,里面說倒是curl的問題:
https://groups.google.com/forum/?fromgroups=#!topic/pongba/sgMYM9dGI7k
根據鏈接里面說的,去官網下載了一個最新版本(curl-7.28.1.tar.gz)的curl,來進行源碼編譯。
編譯的依賴,openssl和openssl-devel。
編譯方法和其他軟件類似,步驟如下:
去到源碼目錄:curl-7.28.1
./configure --without-nss --with-ssl && make &&make install 即可完成編譯。
然后是把curl的lib添加到PATH中,這個也是在google group里面說到的。
ldconfig(echo "/usr/local/lib" >> /etc/ld.so.conf && 這個有時候需要重啟服務器后,再次執行這個命令.重啟有問題,還是按下面的標准更新流程來!)
此時,通過命令行運行php調用curl 帶證書訪問web的php程序可以正常了。但是通過web界面還是之前那個Unable to load client key -8178 問題,需要重新編譯php。
====
最新流程2018-05-14
先yum update openssl
再yum update curl
curl -V
如果直接顯示已經是OpenSSL版本了
重啟一下php-fpm即可,不需要下面的方式。。。
上面的yum方式不行的話,走這個更新流程
1、系統的curl生成
wget http://curl.haxx.se/download/curl-7.35.0.tar.gz
tar -zxvf curl-7.35.0.tar.gz
cd curl-7.35.0.tar.gz
cd /www/src/curl-7.39.0
./configure --prefix=/usr/local/curl --without-nss --with-ssl
make && make install
備份默認的curl二進制文件
sudo mv /usr/bin/curl /usr/bin/curl.bak
然后做一個新的curl軟鏈
sudo ln -s /usr/local/curl/bin/curl /usr/bin/curl
然后再curl --version確認是否已經是openssl的版本
2、生成curl.so
cd /www/src/lanmp/php-5.2.17/ext/curl
/www/wdlinux/php/bin/phpize
./configure --with-php-config=/www/wdlinux/php/bin/php-config --with-curl=/usr/local/curl/
make && make install
3、重新編譯php(php.ini找出原先的配置參數,復制,去掉with-curl,然后編譯
cd /www/src/lanmp/php-5.2.17/
./configure '--prefix=/www/wdlinux/apache_php-5.2.17' '--with-config-file-path=/www/wdlinux/apache_php-5.2.17/etc' '--with-mysql=/www/wdlinux/mysql' '--with-iconv=/usr' '--with-mysqli=/www/wdlinux/mysql/bin/mysql_config' '--with-pdo-mysql=/www/wdlinux/mysql' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-discard-path' '--enable-inline-optimization' '--enable-mbregex' '--enable-mbstring' '--with-mcrypt=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-ftp' '--enable-bcmath' '--enable-exif' '--enable-sockets' '--enable-zip' '--with-apxs2=/www/wdlinux/apache/bin/apxs'
4、編譯完后,在php.ini里增加
extension=curl.so
重啟php-fpm即可
=====
如果你在linux服務器經常需要安裝新的php應用,那難免會遇到需要重新編譯php,給它增加新的功能的情況。重新編譯php后,一方面需要替換掉原來的php,另一方面需要保障其他在線網站的正常運轉,就需要對php進行平滑替換了。這個過程該如何進行呢?給出一點我在這方面積累的經驗。
1、找出原來php的配置參數
~:php -i|grep configure
Configure Command => './configure' '--prefix=/usr/local/php' '--enable-mbstring' '--enable-fastcgi' '--enable-fpm' '--with-curl' '--with-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config'
./configure '--prefix=/www/wdlinux/apache_php-5.2.17' '--with-config-file-path=/www/wdlinux/apache_php-5.2.17/etc' '--with-mysql=/www/wdlinux/mysql' '--with-iconv=/usr' '--with-mysqli=/www/wdlinux/mysql/bin/mysql_config' '--with-pdo-mysql=/www/wdlinux/mysql' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-discard-path' '--enable-inline-optimization' '--with-curl=/usr/local/curl' '--enable-mbregex' '--enable-mbstring' '--with-mcrypt=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-ftp' '--enable-bcmath' '--enable-exif' '--enable-sockets' '--enable-zip' '--with-apxs2=/www/wdlinux/apache/bin/apxs'