notes icon indicating copy to clipboard operation
notes copied to clipboard

安装最新版的 openssl 和 curl or how to install lastest openssl & curl?

Open lanlin opened this issue 6 years ago • 0 comments

背景

openssl与curl两者往往是配套使用的,比如为了使用 curl 访问 https。 但是在安装时,往往有点蛋痛。这里大致记录下,备忘。

测试组合版本号如下 curl version: 7.64.1 openssl version: 1.1.1b

步骤

  1. 首先干掉可能的干扰项 (ssl lib 等, 根据自己安装情况,自行补充)
sudo yum remove libssl-dev openssl-devel libcurl-devel curl-devel
sudo apt-get remove libssl-dev openssl-devel libcurl-devel curl-devel
  1. 然后安装必要的依赖
sudo yum install libtool perl-core
sudo apt-get install libtool perl-core
  1. 先安装 openssl
sudo rm -rf /usr/bin/openssl
sudo rm -rf /usr/include/openssl
wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz
tar zxf ./openssl-1.1.1b.tar.gz
cd ./openssl-1.1.1b
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared
sudo make
sudo make install
sudo ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
sudo ln -s /usr/local/ssl/include/openssl /usr/include/openssl
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
ldconfig -v
  1. 然后安装 curl
sudo rm -rf /usr/bin/curl && \
wget https://curl.haxx.se/download/curl-7.64.1.tar.gz
tar zxf ./curl-7.64.1.tar.gz
cd ./curl-7.64.1
./configure --prefix=/usr/local/curl --without-nss --with-ssl --with-libssl-prefix=/usr/local/ssl
sudo make
sudo make install
sudo ln -s /usr/local/curl/bin/curl /usr/bin/curl
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig -v
  1. 最后再把两者的开发者库给装上
yum install openssl-devel libcurl-devel
apt-get install openssl-devel libcurl-devel

说明

按照上述步骤应该能避免下面这些问题

  1. 缺少 perl-core,安装 openssl 会导致类似下面的问题
Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run
  1. 有多个 ssl 库,安装 curl 会导致类似下面的问题
vtls/openssl.c: In function ‘Curl_ossl_seed’:
vtls/openssl.c:279:5: error: implicit declaration of function ‘RAND_egd’ [-Werror=implicit-function-declaration]
  1. 注意 openssl 的安装目录,curl 的 --with-ssl 需要与其保持一致

# for openssl
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared

# for curl
./configure --prefix=/usr/local/curl --without-nss --with-ssl --with-libssl-prefix=/usr/local/ssl
  1. 注意 openssl 配置编译项的文件

    与大家默认遵守的命名不同,这个家伙有两个文件。 分别叫做 configConfigure,而且一定要注意 ConfigureC 是大写的!!!

image 这尼玛是坑爹呢

  1. 关于这么做的详细说明,参见维基百科Configure & Config

You use Configure and config to tune the compile and installation process through options and switches. The difference between is Configure properly handles the host-arch-compiler triplet, and config does not. config attempts to guess the triplet, so its a lot like autotool's config.guess.

You can usually use config and it will do the right thing (from Ubuntu 13.04, x64). Mac OS X can have issues (its often a neglected platform), and you will have to use Configure:

简单说就是:Mac OS X 用 Configure, 其他 Linux 用 config

最后

image 祝你好运,Good Luck!

lanlin avatar May 14 '19 10:05 lanlin