Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just made a fresh install of a server with nginx with php5-fpm. Why if you visit a php page that doesn't exist you get a blank page instead of the default "not found" page of nginx? Shouldn't this be handle by the nginx webserver like non php files?


    user www-data;
worker_processes 1;
pid /var/run/;

events {
    worker_connections 768;
    # multi_accept on;

http {

    # Basic Settings

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    # Logging Settings

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    # Gzip Settings

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    # Virtual Host Configs

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;


   server {
        listen 80 default;
        access_log  /var/log/nginx/default.access.log;
        root   /var/www/default/public;

    ## Default location
        location / {
            index index.php;

    ## Images and static content is treated different
        location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
          access_log        off;
          expires           30d;

    ## Parse all .php file in the /var/www directory
        location ~ .php$ {
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_pass   backend;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_param  QUERY_STRING     $query_string;
            fastcgi_param  REQUEST_METHOD   $request_method;
            fastcgi_param  CONTENT_TYPE     $content_type;
            fastcgi_param  CONTENT_LENGTH   $content_length;
            fastcgi_intercept_errors        on;
            fastcgi_ignore_client_abort     off;
            fastcgi_connect_timeout 60;
            fastcgi_send_timeout 180;
            fastcgi_read_timeout 180;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 4 256k;
            fastcgi_busy_buffers_size 256k;
            fastcgi_temp_file_write_size 256k;

    ## Disable viewing .htaccess & .htpassword
        location ~ /\.ht {
            deny  all;

    upstream backend {
share|improve this question
Please edit your post to append the nginx's configuration file. – quanta Sep 16 '11 at 13:50
I can't edit it says page not found :| – Sandro Antonucci Sep 16 '11 at 16:59
Paste it into and insert link here. – quanta Sep 16 '11 at 17:04
i was able to edit from here – Sandro Antonucci Sep 17 '11 at 22:17
up vote 1 down vote accepted

According to the fastcgi_intercept_errors document, you need to define the error_page handler for this. So, add the below line into the location context:

error_page 404 /error/404.php;

it will display the default error page 404 Not Found when accessing the non-exist php files.

You also take a look at fastcgi_params configuration file to avoid duplicate define fastcgi_param.

share|improve this answer
thank you worked! – Sandro Antonucci Sep 18 '11 at 19:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.