NGINX not executing PHP files

it get a "Oops! This link appears to be broken." error in CHROME.

Chrome shows its own error page if the error page is less than 512 bytes.

I suspect that you have the following line in fastcgi_params:

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

and if so, because the root directive is defined in location / will be never applied to location ~ \.php$, thus the SCRIPT_FILENAME becomes URI.

This can be solve by moving the root directive to the server level context:

server {
    listen       80;
    server_name  im;
    access_log /var/www/website/access.log;
    error_log /var/www/website/error.log;

    root   /var/www/website;

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

}

Tags:

Nginx

Php