標籤:http 使用 linux .net re amp
在php程式中使用curl去訪問https網站時,報錯:
Protocol https not supported or disabled in libcurl
該錯誤資訊表示php當時編譯時間使用的curl庫不支援https, 驗證方法為
你的curl安裝目錄/bin/curl -V
顯示如下:
Protocols: dict file ftp gopher http imap pop3 rtsp smtp telnet tftp
這表示curl是不支援 https的
為了支援https,需要下載源碼包,重新編譯curl
tar zxvf curl-7.24.0.tar.gz
cd curl-7.24.0
./configure --prefix=/usr/local/services/curl-7.24.0 --with-ssl=/usr/local/services/openssl-0.9.8a
#請注意,這裡一定要使用 --with-ssl 參數,前提是你已經安裝了openssl-0.9.8a (建議安裝0.9.8a 測試過0.9.7i有些bug)
該步驟執行結束後,一定要觀察仔細,是否有這行
SSL support: enabled (OpenSSL)
如果你的是
SSL support: no
那就是說,你的curl依舊沒有支援https
make && make install
在make的時候,也許你會遇到這樣的錯誤:
`a local symbol‘ can not be used when making a shared object; recompile with -fPIC
libssl.a: could not read symbols: Bad value
解決辦法,請參考http://mylinux.5d6d.net/viewthread.php?tid=1013
安裝完成後,再次運行
curl安裝目錄/bin/curl -V
結果為
Protocols: dict file ftp gopher http https imap pop3 rtsp smtp telnet tftp
這說明已經支援了https
剩下的就是重新編譯php, 當然相應的支援curl的參數為 --with-curl=你的curl安裝目錄