Nginx,默认服务器块看不到php文件 - 但子域可以


Nginx, default server block cannot see php files - but sub domain can

我对Nginx还不是很好,所以我真的很感激在这里提供一点帮助。

现在我的问题是,我的默认服务器块 domain.com,所有php文件都被拒绝访问它们。

www.domain.com/index.php,我得到了正确的403禁止页面。

但是如果我去www.SomeRandomSubDomain.domain.com/index.php我可以看到文件很好。我没有任何其他服务器块。我在下面的第一行中是否缺少某种小标签?

location ~ '.php$ {
            deny all;
            try_files $uri =404;
            fastcgi_split_path_info ^(.+'.php)(/.+)$;
            # NOTE: You should have "cgi.fix_pathinfo = 0;" in
            # php.ini
            # With php5-cgi alone: fastcgi_pass 127.0.0.1:9000;
            # With php5-fpm:
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            #include fastcgi_params;
            include fastcgi.conf;
    }

如果您需要任何其他信息来进一步帮助我,请告诉我,这让我陷入了一个混乱的世界,我在谷歌上没有运气。

这是完整文件:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    server_name EXAMPLE.com www.EXAMPLE.com;
    root /var/www/html;
    index index.html index.php index.htm;
    location / {
            try_files $uri $uri/ $uri.html $uri.php?$query_string;
            # Uncomment to enable naxsi on this location include
            # /etc/nginx/naxsi.rules
            }
    location ~ .(css|img)/(.+)$ {
    try_files $uri $uri/ /$1/$2;
    }
    error_page 404 403 /404.php;
    location ~ '.php$ {
            deny all;
            try_files $uri =404;
            fastcgi_split_path_info ^(.+'.php)(/.+)$;
            # NOTE: You should have "cgi.fix_pathinfo = 0;" in
            # php.ini
            # With php5-cgi alone: fastcgi_pass 127.0.0.1:9000;
            # With php5-fpm:
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            #include fastcgi_params;
            include fastcgi.conf;
     }
 }

尝试从 PHP 配置中删除deny all;