主题
Nginx 升级报错 OpenSSL 问题解决办法
一、报错信息
源码编译 / 升级 Nginx 时,./configure 报错:
bash
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using --with-openssl=<path> option二、解决办法
2.1 下载 OpenSSL 源码
bash
wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz
tar -xvf openssl-1.1.1w.tar.gz2.2 再次执行 configure
关键是增加 --with-openssl=,指向 OpenSSL 源码解压目录(示例为 /root/soft/openssl-1.1.1w,按实际路径修改):
bash
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --with-openssl=/root/soft/openssl-1.1.1w --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'2.3 编译
bash
make2.4 备份旧 Nginx 并替换二进制
bash
cd /usr/sbin/
mv nginx nginx.bak
cp /root/soft/nginx-1.28.0/objs/nginx .NOTE
/root/soft/nginx-1.28.0/ 为 Nginx 源码编译目录,请按实际路径修改。
2.5 重启 Nginx
bash
systemctl restart nginx三、验证升级是否成功
bash
nginx -v预期输出示例:
bash
nginx version: nginx/1.28.0