Nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf

  出现上面标题中的问题是因为我当初在安装Nginx的时候没有安装SSL模块,但是现在我在Nginx配置文件(nginx.cnf)中配置了SSL的相关配置信息。当我再次启动Nginx的时候就提示我nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:111 了。下面我将我的解决方案给记录了下来,供大家参考哦!

解决问题

首先需要申明一下,我安装Nginx的目录是 /usr/local/nginx/ ,当时安装的时候是通过源码安装的,所以源码也在这个目录下面。接下来我们会利用源码加载 SSL 模块重新编译,如果你没有源码则可以选择重新安装新版 Nginx 进行解决。

先来看看 Nginx 的版本吧:

[root@xxx ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.16.1
...
configure arguments: 

可以看到,我这里的configure arguments: 后面没有任何配置参数。

我们现在切换到源码包目录下面,增加SSL配置项进行重新编译:

# 切换到Nginx源码目录下面:
[root@xxx ~]# cd /usr/local/nginx/
# 新增SSL模块进行重新配置:
[root@xxx nginx]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
# 重新编译:
[root@xxx nginx]# make

⚠️注意:这里不在需要执行make install命令了,如果执行了会覆盖之前的安装,会有一定的风险哦!

然后备份原有已安装好的 nginx :

[root@xxx nginx]# cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

停止现有的 Nginx 服务:

[root@xxx ~]# /usr/local/nginx/sbin/nginx -s stop

然后将刚刚编译好的 nginx 覆盖掉原有的 nginx,刚才重新编译好的nginx在/usr/local/nginx/objs/ 下面。

[root@xxx ~]# cp ./objs/nginx /usr/local/nginx/sbin/
# 执行的时候会有个询问过程,询问你是否选择覆盖?此时输入 `yes` 然后按`Enter`就行了。

上述执行成功后,再执行查看 Nginx 版本就可以看到configure arguments: 后面有新的参数了,如下:

[root@xxx nginx]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

通过上面控制台返回的信息可见新增的SSL模块成功了。

重新启动Nginx就可以啦:

# 启动Nginx服务
[root@xxx nginx]# /usr/local/nginx/sbin/nginx

其他

  在Linux系统下安装 Nginx 服务及其配置 SSL 证书实现 HTTPS 访问可以参考下面的文档哦:

  Centos7安装Nginx并配置

  Nginx 配置SSL证书,实现HTTPS访问

  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
问题分析: 根据引用\[1\]和引用\[2\]的错误提示信息,可以得出结论是在nginx的配置文件中使用了ssl参数,但是nginx缺少了ngx_http_ssl_module模块,导致无法识别ssl参数。引用\[3\]提供了解决方法,即需要重新编译安装nginx,并在编译配置中添加--with-http_ssl_module参数。 解决过程: 1. 打开终端,进入nginx的源码目录,例如/usr/local/src/nginx-1.8.0。 2. 运行以下命令来重新配置nginx的编译选项,添加--with-http_ssl_module参数: ./configure --with-http_ssl_module 3. 运行make命令编译nginx: make 4. 运行make install命令安装编译好的nginx: make install 5. 安装完成后,进入nginx的配置文件目录,例如/usr/local/nginx/conf。 6. 打开nginx.conf文件,确保在http块中有以下配置项: http { ... ssl on; ... } 7. 保存并关闭nginx.conf文件。 8. 重新启动nginx服务: /usr/local/nginx/sbin/nginx -s reload 通过以上步骤,你应该能够解决nginx配置文件中缺少ngx_http_ssl_module模块的问题,并成功启用ssl功能。 #### 引用[.reference_title] - *1* [nginx配置SSL数字证书、报错nginx: [emerg] the “sslparameter requires ngx_http_ssl_module in](https://blog.csdn.net/y393016244/article/details/129712192)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [nginx启动报 ssl parameter requires ngx_http_ssl_module](https://blog.csdn.net/yuan_618859/article/details/124918931)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值