一、安装包的下载
(1)Nginx的下载(这里下载最新的稳固版本1.26.1):下载地点nginx: downloadhttps://nginx.org/en/download.html
(2)Pcre的下载(这里选择稳固版本8.41): PCRE download | SourceForge.netDownload PCRE for free. PERL 5 regular expression pattern matching. The Perl Compatible Regular Expressions (PCRE) library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5. PCRE has its own native API, in addition to a set of POSIX compatible wrapper functions.https://sourceforge.net/projects/pcre/,这个是nginx编译安装的依赖包
(3)OpenSSL的下载(这里选择下载最新稳固版本3.3.1):[ Downloads ] - /source/index.htmlhttps://www.openssl.org/source/,主要办理谷歌新版浏览器访问提示“ERR SSL PROTOCOL ERROR”的问题
二、OpenSSL的安装
(1)查看OpenSSL的版本
(2)查看OpenSSL的路径
(3)备份OpenSSL文件
- sudo mv /usr/bin/openssl /usr/bin/openssl_old
- sudo mv /usr/include/openssl /usr/include/openssl_old
复制代码 (4)解压OpenSSL并设置安装目录
- tar –zxvf openssl-3.3.1.tar.gz
复制代码 (5)切换到解压好的openssl目录
(6)设置openssl安装目录
- ./config --prefix=/usr/local/openssl
复制代码
(7)编译与安装
- sudo make && sudo make install
复制代码 等候完成即可
(8)创建软链接
说明:创建的软链接和之前没升级通过whereis openssl保持一致即可。
- ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
- ln -s /usr/local/openssl/include/openssl /usr/include/openssl
复制代码 (9)添加动态链接库数据(注意须要切到root用户才有权限)
- echo "/usr/local/openssl/lib64/" >> /etc/ld.so.conf
复制代码 检查一下,已经在/etc/ld.so.conf中存在:
- include ld.so.conf.d/*.conf
- /usr/local/openssl/lib64/
复制代码 (10)更新动态链接库:
(11)验证openssl
查看openssl版本 openssl version -a会表现全面具体信息
- OpenSSL 3.3.1 4 Jun 2024 (Library: OpenSSL 3.3.1 4 Jun 2024)
- built on: Thu Jun 13 02:55:45 2024 UTC
- platform: linux-x86_64
- options: bn(64,64)
- compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DNDEBUG
- OPENSSLDIR: "/usr/local/openssl/ssl"
- ENGINESDIR: "/usr/local/openssl/lib64/engines-3"
- MODULESDIR: "/usr/local/openssl/lib64/ossl-modules"
- Seeding source: os-specific
- CPUINFO: OPENSSL_ia32cap=0xfefa320b5f8bffff:0x800d19e4fbb
复制代码 (12)到此openssl升级完成
三、Nginx新版本的安装
(1)将下载的好Nginx-1.26.1解压并进入Nginx-1.26.1目录
- tar -zxvf Ninx-1.26.1.gz
- cd /opt/Nginx-1.26.1/
复制代码 (2)查看旧版本Nginx设置的编译文件并复制configure arguments,将openssl对应的版本替换一下
- nginx version: nginx/1.11.3
- built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
- built with OpenSSL 1.0.1 14 Mar 2012
- TLS SNI support enabled
- configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre=../pcre-8.41 --with-openssl=../openssl-1.0.1
复制代码 (3)设置Nginx新版本的编译参数
- [root@web03 nginx-1.24.0]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre=../pcre-8.41 --with-openssl=../openssl-3.3.1
复制代码 (4)实行make,不要make install
- [root@web03 nginx-1.24.0]# sudo make
复制代码 (5)将nginx-1.26.0目录下的nginx放到/usr/local/nginx/sbin/目录下
- [root@web03 sbin]# mv /opt/nginx-1.26.0/objs/nginx /usr/local/nginx/sbin/
- [root@web03 sbin]# ls
- nginx
- [root@web03 sbin]#
复制代码 (6)天生新的nginx master历程
- [root@web03 ~]# cd /usr/local/nginx/logs/
- [root@web03 logs]# cat nginx.pid
- 15210
- [root@web03 logs]# kill -USR2 15210
- [root@web03 logs]# ls
- access.log error.log nginx.pid nginx.pid.oldbin
- [root@web03 logs]#
复制代码 可以看到,当前的nginx历程文件自动命名为nginx.pid.oldbin,又天生了一个新的nginx.pid文件
(7)天生新的nginx master历程
- [root@web03 logs]# cat nginx.pid.oldbin
- 15210
- [root@web03 logs]# kill -WINCH 15210
- [root@web03 logs]# kill -QUIT 15210
- [root@web03 logs]# ls
- access.log error.log nginx.pid
- [root@web03 logs]#
复制代码 旧版本的nginx历程已经被新版本的nginx历程替代
(8)可以看到当前版本已经升级到了1.26.1
- [root@web03 logs]# /usr/local/nginx/sbin/nginx -V
- nginx version: nginx/1.26.1
- built by gcc 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
- built with OpenSSL 3.3.1 4 Jun 2024
- TLS SNI support enabled
- configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre=../pcre-8.41 --with-openssl=../openssl-3.3.1
复制代码 (9)访问页面测试:输入网站即可
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |