nginx:[emerg] /etc/nginx/sites-available/domain.com:1 中不允许使用“server”指令

nginx:[emerg] /etc/nginx/sites-available/domain.com:1 中不允许使用“server”指令

我在自定义网站的 nginx 配置方面遇到了问题,但我不知道问题出在哪里。我已经有 2 个网站在运行,正在添加第 3 个,我已经从一个网站复制并修改了配置文件,但我收到错误,提示第 1 行不允许使用服务器指令。

谁能指出我哪里出了问题?

以下是来自 nginx.conf 和 domain.com 配置文件的 c/p:

nginx.conf

# Generic startup file.
user  nginx;

#usually equal to number of CPUs you have. run command "grep processor /proc/cpuinfo | wc -l" to find it
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

# Keeps the logs free of messages about not being able to bind().
#daemon     off;

events {
        worker_connections  1024;
}

http {
#       rewrite_log on;

        include            /etc/nginx/mime.types;
        default_type       application/octet-stream;
        access_log         /var/log/nginx/access.log;
        sendfile           on;
        keepalive_timeout  3;
#       tcp_nopush         on;
#       tcp_nodelay        on;
        gzip               on;

#php max upload limit cannot be larger than this
        client_max_body_size 13m;
        index index.php index.html index.htm;

        # Upstream to abstract backend connection(s) for PHP.
        upstream php {
                #this should match value of "listen" directive in php-fpm pool
                server unix:/var/run/php5-fpm.sock;
#               server 127.0.0.1:9000;
        }

        include sites-enabled/*;
}

域名.com

Custom site rules:

server {

    listen 80;
    listen [::]:80;

    server_name domain.com *.domain.com;

    root /var/www/html/domain.com/;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /var/www/html/domain.com;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

相关内容