欢迎光临
我们一直在努力

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

nginx配置ssl证书报错

遇到的错误 nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module 表明Nginx在编译安装时没有包含SSL模块,因此无法处理HTTPS配置。
在这里插入图片描述

一、解决方案:重新编译Nginx,添加SSL模块

这是最标准、可控性最高的方法。你需要进入Nginx源码目录,在现有编译参数的基础上增加 –with-http_ssl_module 模块,然后重新编译和安装。

操作步骤:

  • 查看当前Nginx的编译参数

    nginx -V 2>&1 | grep arguments

    这会输出一长串 –with-… 的参数,请完整复制保存下来,下一步会用到。

  • 进入Nginx源码目录
    如果你当初是从源码编译安装的,应该知道源码在哪。如果找不到,可能需要重新下载一个与你当前版本一致的Nginx源码包。

    # 例如,进入一个临时目录并下载源码(以1.24.0版本为例,版本号务必匹配)
    cd /usr/local/src
    wget http://nginx.org/download/nginx-1.24.0.tar.gz
    tar -zxvf nginx-1.24.0.tar.gz
    cd nginx-1.24.0

  • 配置、编译和安装
    使用上一步保存的原有参数,并额外加上 –with-http_ssl_module。

    ./configure [你之前保存的所有原参数] –with-http_ssl_module

    例如,你的命令可能看起来像这样:

    ./configure –prefix=/usr/local/nginx –with-http_stub_status_module ... –with-http_ssl_module

    配置完成后,执行编译。注意:make 之后不要执行 make install,这会覆盖配置文件。

    make

  • 备份旧程序并替换新程序

    # 备份旧的nginx可执行文件
    cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.backup
    # 将新编译好的程序复制过去
    cp objs/nginx /usr/local/nginx/sbin/

  • 测试并重载

    # 测试新程序是否工作
    /usr/local/nginx/sbin/nginx -t
    # 如果显示成功,则平滑重启
    /usr/local/nginx/sbin/nginx -s reload

  • 二、验证解决

    完成后,执行 nginx -V,查看输出中是否包含 –with-http_ssl_module。如果包含,说明SSL模块已就绪。

    然后执行nginx -t,显示**nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful**即成功了。

    image-20251219213639584

    赞(0)
    未经允许不得转载:171主机测评 » nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:
    分享到: 更多 (0)

    评论 抢沙发

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址