Some Issues with Configuration

Francis Daly francis at
Sun Mar 9 11:06:42 UTC 2014

On Sat, Mar 08, 2014 at 09:02:37PM +0000, Richard Ibbotson wrote:

Hi there,

> NGINX is serving up static HTML pages but I now find that WordPress 
> pages are being served as plain text.

nginx uses a single config file.

There is an "include" directive where other files are (effectively)
copied in to the configuration when nginx reads it.

Any file not mentioned in an "include" directive is irrelevant to nginx.

When a request comes in, nginx uses the "listen" and "server_name"
directives in every "server" block to choose the one "server" block that
will handle this request.

If you only have a single "server" block, that's the one that will be
used. If you have more than one, make sure that you can know which one
will be used for the request you are making.

After any server-level rewrite-module directives, nginx chooses a
single "location" block in which to process the request. In that block,
there will either be a directive that causes the request to be handled
elsewhere -- e.g. proxy_pass or fastcgi_pass -- or there is a default
"serve it from the filesystem".

(There are also subrequests and internal rewrites within nginx; there
may be more than one nginx request associated with a single incoming
http request.)

So, in each case where the output is not what you want, you should be
able to say something like

I request
I want a 301 redirection to
I get a 301 redirection to


I request
I want the php-processed content of the file /var/www/blog/index.php
I get the unprocessed content of the file /var/www/blog/index.php

and with that information, you should be able to see which one location
was used to process the request; and you should be able to see why the
response was what it was.

In your specific case of unprocessed content, the most likely thing
is that the one location that processed your request did not have any
other "handle it elsewhere" directives, and so a file was served from
the filesystem.

The config snippet you provided has no "fastcgi_pass" directives, but
it does have some "include" directives, so it is possible that there is
configuration in one of those files that affects this request.

Without those "include" files, it looks like "location /" would be the
one that would handle your request (whether it is /blog, /blog/, or
/blog/index.php); and that just says "serve it from the filesystem".

> What do I have to change to make this work properly ?

Tell nginx what you want it to do with requests for php files, if it
isn't just "serve it from the filesystem".

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list