php中curl不支援https的解決辦法

來源:互聯網
上載者:User

標籤: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安裝目錄

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.