I have a simple PHP script that outputs a dir listing in XML format. I use it to let a flash slideshow know what files are available to show.
I’ve just added the flash to a website that’s powered by Django and the PHP file is now served up as it is, not parsed.
It’s in the directory with the images under my media directory.
The server I use runs plesk so I do my config for each domain in a vhost.conf file (which gets included into the main appache conf I think)
It looks like this:
WSGIScriptAlias / /var/www/vhosts/<domain>/conf/django.wsgi
Alias /media/ /var/www/vhosts/<domain>/httpdocs/media/
I thought this meant that requests for anything under / are passed django to handle.
Except when they are for /media/… then they are served by apache as normal from the specified dir.
That works for the images, but does not parse the PHP file.
What should I do?
4
Answers
So it turns out the problem was two things, making it hard to find.
Thanks Ignacio Vazquez-Abrams, I had my lines the wrong way around.
Once that was solved, PHP would not serve my file because it was in a dir that was symlinked from outside the
allowed path(s)
. I resolved this by turning off open_basedir restrictions for this vhost. My newvhost.conf
is below.Maybe read this thread, and port your PHP script to Python:
os.walk() python: xml representation of a directory structure, recursion
If you have not configured Apache so that it knows that .php files under the ‘/media’ directory should be processed by PHP somehow, they will not be. So, the mod_wsgi configuration is fine, the problem is likely your PHP configuration.
How are you configuring PHP? Are you using mod_php, or PHP via fastcgi? How is Apache configured so that it knows to treat .php files as PHP and for what directories has that configuration been applied to?
The
WSGIScriptAlias
directive there swallows up URLs meant forAlias
. Swap the order.