Nginx经常返回404

时间:2017-07-23 15:35:18

标签: php nginx http-status-code-404 ubuntu-14.04

我在Ubuntu 14.04中安装了Nginx 1.4的服务器,并且运行PHP5-fpm。服务器在私有云服务器中具有多个域和子域。服务器从流量中获得了一致的点击量。一切都很好,但Nginx经常返回404,而案例不是实际的,经过几次尝试它返回实际输出而不是404.下面是我的一个nginx配置服务器块的例子。

    server {
    listen 80;
    #listen [::]:80;

    root /var/www/appfolder;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name domain-name;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
        # Uncomment to enable naxsi on this location
        # include /etc/nginx/naxsi.rules
    }

    # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
    #location /RequestDenied {
    #   proxy_pass http://127.0.0.1:8080;    
    #}

    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 /var/www/appfolder;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        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 unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #   deny all;
    #}
   }

请帮助我,我已经搜索了很多,但从来没有得到适当的解决方案。 提前致谢

0 个答案:

没有答案
相关问题