# Nginx and PHP, subdirectories not working

**URL:** <https://www.ruby-forum.com/t/nginx-and-php-subdirectories-not-working/209297>\
**Category:** NGINX\
**Created:** [July 11, 2011, 8:03am UTC](https://www.ruby-forum.com/t/nginx-and-php-subdirectories-not-working/209297 "2011-07-11T08:03:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [July 11, 2011, 8:03am UTC](https://www.ruby-forum.com/t/nginx-and-php-subdirectories-not-working/209297/1 "2011-07-11T08:03:48Z")

</div>

Hello list! Joined to post this but I’ll be idle.

I’m having problems with my setup for a server (Lucid x86). Because  
it’s personal, I keep everything under the same root. I’m trying to  
get it to where I can run mediawiki, but I can’t get php files to work  
in subdirectories. That is, with my root as /var/www,  
/var/www/test.php works fine but not /var/www/wiki/test.php

My config file for nginx is posted, with changed extension, at:  
[http://copb.sleepingwolf.net/roots/shared/nginxconfig.txt](http://copb.sleepingwolf.net/roots/shared/nginxconfig.txt)

Likewise, the server config at:  
[http://copb.sleepingwolf.net/roots/shared/serverconfig.txt](http://copb.sleepingwolf.net/roots/shared/serverconfig.txt)

Anyone have any advice on how to fix the problem? Reading files from  
all over the web and the wiki have me at my wits end ~ I have php5-fpm  
installed, for what it’s worth… and, likewise, for example’s sake:

[http://copb.sleepingwolf.net/phpcheck.php](http://copb.sleepingwolf.net/phpcheck.php)  
versus  
[http://copb.sleepingwolf.net/nginx-default/phpcheck.php](http://copb.sleepingwolf.net/nginx-default/phpcheck.php)

I assure you - the file is there in both cases, has the exact same  
permission settings at both directory and file level, and is exactly  
the same function call (phpinfo).

Thanks in advance,  
~James

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 11, 2011, 8:08am UTC](https://www.ruby-forum.com/t/nginx-and-php-subdirectories-not-working/209297/2 "2011-07-11T08:08:46Z")

</div>

On Mon, Jul 11, 2011 at 1:03 PM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I assure you - the file is there in both cases, has the exact same  
> permission settings at both directory and file level, and is exactly  
> the same function call (phpinfo).

move  
root /var/www/;  
to top level (on `server { }` block, not `location / { }` block)

change this line  
fastcgi\_param SCRIPT\_FILENAME  
//var/www/nginx-default$fastcgi\_script\_name;  
to this  
fastcgi\_param SCRIPT\_FILENAME $request\_filename;
