How to setup nginx to make php works in site subdirectories

Dmitry Timoshenko dimentiy2k at
Sun Feb 12 10:59:43 UTC 2012


I'm nuewbie in nginx, I've installed and setup nginx & php,
everything is fine except .php files located in site's subdirectories 
are not processed at all.

i.e. works fine, but is sent to client as plain text.

Please, would any kind soul tell me what should I change to resolve the 
Thank you.

I use those settings.


server {
     listen   80;

     access_log  /var/log/nginx/;

     location / {
         root   /var/www/nginx-default/;
         index  index.html index.htm index.php;

## 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  
         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 {

More information about the nginx mailing list