linux中nginx配置訪問路徑

Linux中,配置nginx訪問home文件夾彙總的eakom文件夾,其配置如下

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root htm;
        index  index.html index.htm;
    }
    location /eakom/ {
        root /home;
        autoindex on;
        index  index.html index.htm;
    }
    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

訪問是出現異常
這裏寫圖片描述
查看nginx日誌error.log日誌
這裏寫圖片描述
日誌中顯示,訪問http://192.168.158.99/eakom/時,自動跳到Linux安裝目錄根路徑下htm文件中,注意:其中htm路徑爲nginx默認配置的路徑,其配置代碼如下
這裏寫圖片描述
nginx的nginx.conf配置文件默認配置user nobody 其意思爲nginx默認沒有配置用戶,其根路徑爲nginx的安裝路徑,故不能指定訪問路徑

解決方案,在nginx.conf 配置文件中的第二行新增一行代碼
user root;
這裏寫圖片描述

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