配置 nginx server 出現nginx: [emerg] "root" directive is duplicate in /etc/nginx/server/blogs.conf:7


在配置nginx 虛擬機時,執行

sudo /usr/sbin/nginx -t

報下面的錯誤:

nginx: [emerg] "root" directive is duplicate in /etc/nginx/server/blogs.conf:7
nginx: configuration file /etc/nginx/nginx.conf test failed

 

錯誤原因是:在配置文件時,訪問路徑設置了兩個,重復配置webroot路徑導致,去掉一個就可以了。

 

server {
        listen 80 default_server;

 #root /usr/share/nginx/html/;去掉這行
        index index.html index.htm;
        # Make site accessible from http://localhost/
        root /home/wangkongming/webroot/blogs;

        index index.html index.htm;
        server_name blogs.local;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
        access_log /data/logs/blogs/access.log;
        error_log /data/logs/blogs/error.log;

}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM