How to setup nginx to make php works in site subdirectories

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


Hello,

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. example.com/download.php works fine, but
example.com/stuff/dosomething.php is sent to client as plain text.

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

I use those settings.

#
# example.com
#

server {
     listen   80;
     server_name  example.com;

     access_log  /var/log/nginx/example.com.access.log;

     location / {
         root   /var/www/nginx-default/example.com;
         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  
/var/www/nginx-default/example.com$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 {
         server 127.0.0.1:9000;
}



More information about the nginx mailing list