openssl升级
查看openssl版本
openssl version,一般腾讯云为1.0.2k版本到官网www.openssl.org查看最新版本openssl,现在最新为1.1.1h版
下载最新的openssl
wget https://www.openssl.org/source/openssl-1.1.1h.tar.gz解压并编译安装
tar -zxvf openssl-1.1.1h.tar.gzcd openssl-1.1.1h./config --prefix=/usr/local/openssl #如果此步骤报错,需要安装perl以及gcc包make && make installmv /usr/bin/openssl /usr/bin/openssl.bakln -sf /usr/local/openssl/bin/openssl /usr/bin/opensslecho "/usr/local/openssl/lib" >> /etc/ld.so.confldconfig -v # 设置生效再次查看openssl版本
openssl version
升级nginx
wget http://nginx.org/download/nginx-1.18.0.tar.gztar -zxvf nginx-1.18.0.tar.gzcd nginx-1.18.0/./configure --prefix=/usr/local/nginx./configure --with-http_ssl_module./configure --with-openssl=/usr/local/openssl#安装openssl的位置
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --with-file-aio --with-openssl=/usr/local/openssl
make只升级Nginx的话只需makecp objs/nginx /usr/local/nginx/sbin/nginx
编译小错误
/bin/sh: line 2: ./config: No such file or directory
make[1]: *** [/usr/local/ssl/.openssl/include/openssl/ssl.h] Error 127
make[1]: Leaving directory `/usr/local/src/nginx-1.18.0’
make: *** [build] Error 2
根据报错信息我们知道,出错是因为Nginx在编译时并不能在/usr/local/ssl/.openssl/ 这个目录找到对应的文件,其实我们打开/usr/local/ssl/这个目录可以发现这个目录下是没有.openssl目录的,因此我们修改Nginx编译时对openssl的路径选择就可以解决这个问题了
解决方案:
打开nginx源文件下的/usr/local/src/nginx-1.9.9/auto/lib/openssl/conf文件:
找到这么一段代码:
CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"
CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
修改成以下代码:
CORE_INCS="$CORE_INCS $OPENSSL/include"
CORE_DEPS="$CORE_DEPS $OPENSSL/include/openssl/ssl.h"
CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libssl.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libcrypto.a"
CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
然后再进行Nginx的编译安装即可
个人技术小博客:milktop.cn