Welcome! Log In Create A New Profile

Advanced

can't run php in aliased directory outside the root directory

February 23, 2012 04:12PM
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;
}
Subject Author Posted

can't run php in aliased directory outside the root directory

caleboconnell February 23, 2012 04:12PM

Re: can't run php in aliased directory outside the root directory

Francis Daly February 23, 2012 05:38PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 60
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready