How to setup nginx to make php works in site subdirectories

dimentiy nginx-forum at nginx.us
Sun Feb 12 17:48:42 UTC 2012


Hello, Joe,

behind what /? 

I've tried different variants. But I really misunderstand how it should
be.

The goal is to make nginx process .php files whereever they located
begining from site's root folder.

This settings works fine with scripts in site's root.

location ~ \.php$ {
    root       /var/www/nginx-default/example.com;
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME 
/var/www/nginx-default/example.com$fastcgi_script_name;
		include fastcgi_params;
	}

This redirects 'example.com/popups/popup_on_enter.php' to php-fpm but it
returns 'File not found'.

location /popups/popup_on_enter.php {
    root                /var/www/nginx-default/example.com/popups;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index   index.php;
    fastcgi_param  SCRIPT_FILENAME 
/var/www/nginx-default/example.com/popups$fastcgi_script_name;
    include            fastcgi_params;
}

I suppose there sould be variant with one 'location' directive
processing all the files in /var/www/nginx-default/example.com.
But due to my little experience I can't realize how to reach the goal.

Thank you.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,222301,222314#msg-222314



More information about the nginx mailing list