https://curl.haxx.se/download.html
首先去curl官網下載對應版本,這裏有個坑需要注意。如果下載的源碼版本太高,編譯是成功的,但是curl可執行文件訪問https的時候還是會報各種奇怪的錯誤。所以我這裏的做法是,先yum install curl,然後curl -V看我的系統yum支持的curl最新版本。我這裏是7.29.0
這裏點擊Old Releases,可以找到curl-7.29.0.tar.gz
https://www.openssl.org/source/
其次去openssl官網下載對應版本,需要openssl的原因是,如果只編譯curl那麼就不支持https協議了,使用curl訪問https會報錯curl: (1) Protocol https not supported or disabled in libcurl
這裏也是一樣,我也是先yum install openssl然後openssl version查看了最新版本,我這裏是1.0.2k
這裏點擊Old Releases,可以找到openssl-1.0.2k.tar.gz
1. 解壓openssl-1.0.2k.tar.gz,編譯
./config shared --prefix=/tmp/ssl
make
make install
--prefix後面跟的安裝目錄。如果這裏報錯Makefile is older than Makefile.org, Configure or config.那就先./config,再執行上面三步。
2. 解壓curl-7.29.0.tar.gz,編譯
./configure --prefix=/tmp/curl --without-nss --with-ssl=/tmp/ssl
make
make install
--prefix後面跟的安裝目錄
--without-nss是因爲centos自帶的curl支持的https是nss版本的,不是openssl的,我們這裏要用openssl版本的
這是centos自帶的curl,可以看到使用的nss版本
--with-ssl後面跟的openssl安裝目錄
如果我們直接./configure,默認是不支持https協議的
./configure --prefix=/tmp/curl --without-nss --with-ssl=/tmp/ssl執行就有了
3. 最後我們可以在/tmp/curl/bin下看到編譯成功的curl可執行文件,在/tmp/curl/lib下看到我們編譯成功的lib庫,看下現在編譯成功的curl