Nginx配置SSL报错 nginx:[emerg] unknown directive “ssl”

前言:配置Nginx + sll 报错nginx: [emerg] unknown directive "ssl" in /usr/local/nginx/conf/nginx.conf:43,本章将详细说明如何解决

一、报错演示

在这里插入图片描述

二、问题解决

  1. 去nginx解压目录下执行

    如果删了就去在下载吧

    ./configure --with-http_ssl_module
    

    如果报错./configure: error: SSL modules require the OpenSSL library.则执行下边的

    yum -y install openssl openssl-devel
    ./configure
    ./configure --with-http_ssl_module
    
  2. 执行 make(切记不能 make install 会覆盖安装目录)

    make
    
  3. 将原来 nginx 备份

    cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
    
  4. 将新的 nginx 覆盖旧安装目录

    cp -rfp objs/nginx /usr/local/nginx/sbin/nginx
    
  5. 测试 nginx 是否正确

    /usr/local/nginx/sbin/nginx -t
    

    错误运行结果(说明配置失败):

    [root@localhost nginx-1.9.9]# /usr/local/nginx/sbin/nginx -t
    nginx: [emerg] unknown directive "ssl" in /usr/local/nginx/conf/nginx.conf:43
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
    [root@localhost nginx-1.9.9]# 
    

    正确运行结果(说明配置成功):

    [root@localhost nginx-1.9.9]# /usr/local/nginx/sbin/nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    [root@localhost nginx-1.9.9]# 
    
  6. 到这里问题就解决了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章