can't run php in aliased directory outside the root directory
caleboconnell
nginx-forum at nginx.us
Thu Feb 23 21:12:49 UTC 2012
A quick explanation as to what I'm trying to accomplish.
We have a website where we want to keep a media folder outside the root.
This holds all of our large images and videos and mp3 files. We don't
want to keep this in our git repo for deployment since it's only used on
the live site. We've used root to change the root location of a path
name.
Recently we've wanted to store some php files in this media folder, in a
sub-directory to work as front ends to some large swf files we're
hosting. I've added an additional location block to hopefully match the
request to this sub-directory in the media folder to host some php
files. When I go to the page, instead of processing the php, it just
downloads the file.
Below is the config section of our sites-available file that defines the
site.
The actual path to the PHP fie we want to run is:
/var/www/media/courses/OCT-CIPPE/player.php.
The path will always be /var/www/media/courses but the OCT-CIPPE will
change based on the program we want to host. The php file will always
be titled player.php.
Any help/suggestions as to how to change this so it will see the php
file as a file it passes to php5-fpm.
## Web conference alias and flash video settings
location ^~ /media {
root /var/www;
}
location ~ /media/courses/.*\.php$ {
root /var/www;
if ($fastcgi_script_name ~ /media/courses(/.*\.php)$) {
set $valid_fastcgi_script_name $1;
}
fastcgi_pass unix:/tmp/phpfpm.sock;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include fastcgi_params;
}
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,222911,222911#msg-222911
More information about the nginx
mailing list