nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:5

Posted zengjf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:5相关的知识,希望对你有一定的参考价值。

/************************************************************************************************
 *  nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:57
 * 说明:
 *     VPS安装Ubuntu 16.04,调一下Nginx的php Server。
 *
 *                                              2017-9-26 深圳 龙华樟坑村 曾剑锋
 **********************************************************************************************/

一、参考文档:
    1. 启动 nginx 失败 "fastcgi_pass" directive is duplicate
        http://www.cnblogs.com/cgjcgs/p/5310031.html

二、错误现象:
    root@localhost:/var/www/html# systemctl status nginx.service
    鈼?[0m nginx.service - A high performance web server and a reverse proxy server
       Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
       Active: failed (Result: exit-code) since Tue 2017-09-26 01:45:11 EDT; 1min 20s ago
      Process: 345 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

    Sep 26 01:45:11 localhost systemd[1]: Starting A high performance web server and a reverse proxy server...
    Sep 26 01:45:11 localhost nginx[345]: nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:57
    Sep 26 01:45:11 localhost nginx[345]: nginx: configuration file /etc/nginx/nginx.conf test failed
    Sep 26 01:45:11 localhost systemd[1]: nginx.service: Control process exited, code=exited status=1
    Sep 26 01:45:11 localhost systemd[1]: Failed to start A high performance web server and a reverse proxy server.
    Sep 26 01:45:11 localhost systemd[1]: nginx.service: Unit entered failed state.
    Sep 26 01:45:11 localhost systemd[1]: nginx.service: Failed with result \'exit-code\'.

三、解决办法:
    1. 修改文件:/etc/nginx/sites-enabled/default
    2. 如下:
        location ~ \\.php$ {
            ...
            #    fastcgi_pass 127.0.0.1:9000; (此处和下面重复,注释掉)
            #    # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;(此处和上面重复)
            ...
        }

 

以上是关于nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:5的主要内容,如果未能解决你的问题,请参考以下文章

nginx: [emerg] "server" 指令在这里不允许

nginx:[emerg]unknown directive "ssl"

nginx: [emerg] "upstream" directive is not allowed

nginx: [emerg] getpwnam("www") failed

django- nginx: [emerg] open() "/etc/nginx/proxy_params" 在 /etc/nginx/sites-enabled/myproje

nginx 启动报错 nginx: [emerg] getgrnam("root") failed