nginx关于配置SSL后启动失败原因分析
在配置SSL后,启动./nginx失败,报错提示如下:
nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx-1.27.4/conf/nginx.conf:36
这个错误提示表在配置nginx启用SSL时,nginx未启用 ngx_http_ssl_module
模块,因此无法使用 ssl
参数。
ngx_http_ssl_module
是一个必须的模块,提供了 SSL 和 TLS 支持。要解决这个问题,你需要确保在编译 nginx 时启用了 ngx_http_ssl_module
。
解决方法:
1、检查 Nginx 是否启用了 SSL 模块
检查 Nginx 是否已经启用了 ngx_http_ssl_module
模块。切换到sbin目录下,通过以下命令查看 Nginx 的编译配置:
./nginx -V
输出的内容中,应该包含 --with-http_ssl_module
,如果没有,说明 Nginx 编译时没有启用 SSL 模块。
2、检测是否安装了OpenSSL,执行命令:
openssl version
安装显示结果:
如果没有安装,则下载安装包进行安装,这里不详述了。
3、重新编译 Nginx 启用 ngx_http_ssl_module
切换到nginx目录执行命令:
./configure --with-http_ssl_module --prefix=/usr/local/nginx-1.27.4
make
sudo make install
执行完再次检查是否安装成功:
有configure arguments: --with-http_ssl_module --prefix=/usr/local/nginx-1.27.4 则表示已经安装成功,并启用了SSL
现在再启动nginx就成功了