工具系列 | 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 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章