工具系列 | Ubuntu18.04安装Openssl-1.1.1


1.查看版本

Ubuntu的版本是18.04。使用openssl version命令查看openssl版本,可以看到Ubuntu自带了openssl-1.1.0版本,因此安装新版本需要替换旧版本。

www@manager1:~$ openssl version
OpenSSL 1.1.0g  2 Nov 2017

2.下载openssl

打开openssl官网的下载页面可以看到最新的软件包,下载openssl-1.1.1b.tar.gz。放到Ubuntu系统中。

3.解压和安装

  • 使用命令tar -xzvf openssl-1.1.1h.tar.gz 解压。

  • 使用cd openssl-1.1.1h 进入目录,并且使用./config生成MakeFile,不加任何参数,默认的安装位置为:/usr/local/bin/openssl

  • 使用 make 进行编译

  • 不放心的话可以使用make tset检查一下(可选步骤)

  • 使用sudo make install进行安装,这里一定要选择root用户的权限执行。

4.备份与替换

到上一步openssl就算安装好了,但是还无法使用,需要通过软链接的方式将新旧版本就行替换,依次运行下列命令。

sudo mv /usr/bin/openssl /usr/bin/openssl.old    //将旧版本的openssl进行备份
sudo ln -s /usr/local/bin/openssl /usr/bin/openssl    //将新版本的openssl进行软链接
cd /etc/   //进入etc目录
su     //下一步一定要切换到root用户
echo "/usr/local/lib" >> ld.so.conf    //将openssl的安装路径加入配置中
ldconfig  //重新加载配置

如果需要更换版本的话(一般也不会),修改软链接的名称即可,参照:使用openssl version查看,已经安装好。

root@manager1:/etc# openssl version
OpenSSL 1.1.1h  22 Sep 2020

 如果需要更换版本的话(一般也不会),修改软链接的名称即可,参照:

sudo mv /usr/bin/openssl /usr/bin/openssl.new
sudo mv /usr/bin/openssl.old /usr/bin/openssl

更新依赖包

www@manager1:~$ sudo apt-get update
Hit:1 http://mirrors.cloud.aliyuncs.com/ubuntu bionic InRelease
Get:2 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security InRelease [88.7 kB]
Get:4 http://openresty.org/package/ubuntu bionic InRelease [2,827 B]
Get:5 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/universe Sources [434 kB]
Get:7 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/main Sources [496 kB]
Get:8 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/main amd64 Packages [1,751 kB]
Get:9 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/main i386 Packages [1,154 kB]
Get:10 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/main Translation-en [370 kB]
Get:11 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/universe amd64 Packages [1,691 kB]
Get:12 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/universe i386 Packages [1,546 kB]
Get:13 http://openresty.org/package/ubuntu bionic/main i386 Packages [2,441 B]
Get:14 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/universe Translation-en [355 kB]
Get:15 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security/main Sources [237 kB]
Get:16 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Get:17 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security/universe Sources [270 kB]
Get:18 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security/main amd64 Packages [1,424 kB]
Get:19 http://openresty.org/package/ubuntu bionic/main amd64 Packages [22.8 kB]
Get:20 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security/main i386 Packages [859 kB]
Get:21 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security/main Translation-en [280 kB]
Get:22 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security/universe i386 Packages [966 kB]
Ign:6 https://pkg.jenkins.io/debian-stable binary/ InRelease
Get:23 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security/universe amd64 Packages [1,088 kB]
Get:24 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security/universe Translation-en [243 kB]
Get:25 https://download.docker.com/linux/ubuntu bionic/edge amd64 Packages [13.1 kB]
Hit:26 http://ppa.launchpad.net/certbot/certbot/ubuntu bionic InRelease
Get:27 https://pkg.jenkins.io/debian-stable binary/ Release [2,044 B]
Get:28 https://pkg.jenkins.io/debian-stable binary/ Release.gpg [833 B]

重新安装

www@manager1:~$ sudo apt-get install libssl-dev Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: daemon gyp javascript-common libjs-async libjs-inherits libjs-jquery libjs-node-uuid libjs-underscore liblua5.1-0 liblua5.1-0-dev libtool-bin libuv1-dev lua-any lua-sec lua-socket lua5.1 node-abbrev node-ansi node-ansi-color-table node-archy node-async node-balanced-match node-block-stream node-brace-expansion node-builtin-modules node-combined-stream node-concat-map node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fs.realpath node-fstream node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs node-hosted-git-info node-inflight node-inherits node-ini node-is-builtin-module node-isexe node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp node-mute-stream node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-path-is-absolute node-pseudomap node-qs node-read node-read-package-json node-request node-retry node-rimraf node-semver node-sha node-slide node-spdx-correct node-spdx-expression-parse node-spdx-license-ids node-tar node-tunnel-agent node-underscore node-validate-npm-package-license node-which node-wrappy node-yallist openresty-openssl openresty-pcre openresty-zlib python-pkg-resources Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: libssl1.0.0 libssl1.1 Suggested packages: libssl-doc The following packages will be REMOVED: libssl1.0-dev node-gyp nodejs-dev npm The following NEW packages will be installed: libssl-dev The following packages will be upgraded: libssl1.0.0 libssl1.1
2 upgraded, 1 newly installed, 4 to remove and 384 not upgraded. Need to get 3,955 kB of archives. After this operation, 11.0 MB disk space will be freed. Do you want to continue? [Y/n] y Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/main amd64 libssl1.1 amd64 1.1.1-1ubuntu2.1~18.04.6 [1,301 kB]
Get:2 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/main amd64 libssl1.0.0 amd64 1.0.2n-1ubuntu5.4 [1,088 kB]
Get:3 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/main amd64 libssl-dev amd64 1.1.1-1ubuntu2.1~18.04.6 [1,566 kB]
Fetched 3,955 kB in 0s (10.2 MB/s) Preconfiguring packages ... (Reading database ... 139466 files and directories currently installed.) Removing npm (3.5.2-0ubuntu4) ... Removing node-gyp (3.6.2-1ubuntu1) ... Removing nodejs-dev (8.10.0~dfsg-2ubuntu0.4) ... Removing libssl1.0-dev:amd64 (1.0.2n-1ubuntu5.1) ... (Reading database ... 136272 files and directories currently installed.) Preparing to unpack .../libssl1.1_1.1.1-1ubuntu2.1~18.04.6_amd64.deb ... Unpacking libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.6) over (1.1.0g-2ubuntu4.1) ... Preparing to unpack .../libssl1.0.0_1.0.2n-1ubuntu5.4_amd64.deb ... Unpacking libssl1.0.0:amd64 (1.0.2n-1ubuntu5.4) over (1.0.2n-1ubuntu5.1) ... Selecting previously unselected package libssl-dev:amd64. Preparing to unpack .../libssl-dev_1.1.1-1ubuntu2.1~18.04.6_amd64.deb ... Unpacking libssl-dev:amd64 (1.1.1-1ubuntu2.1~18.04.6) ... Setting up libssl1.0.0:amd64 (1.0.2n-1ubuntu5.4) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Setting up libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.6) ... Checking for services that may need to be restarted...done. Checking for services that may need to be restarted...done. Checking init scripts... Restarting services possibly affected by the upgrade: Services restarted successfully. Processing triggers for man-db (2.8.3-2ubuntu0.1) ... Setting up libssl-dev:amd64 (1.1.1-1ubuntu2.1~18.04.6) ... Processing triggers for libc-bin (2.27-3ubuntu1) ...

https://www.cnblogs.com/jsjliyang/p/10606908.html 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM