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. 到這裏問題就解決了

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