Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to set up a Django site at the root of a domain, but then have a Wordpress installation in a subdirectly (e.g. /blog/). How would one configure NGinX to do this? "Pretty" URLs have to work for Wordpress as well.

For Django I am using Gunicorn, which is already configured. From NGinX I would call "proxy_pass" to direct to that. PHP is run via FPM.

Considering the restrictions above, how would I configure NGinX? Any help would be appreciated!


UPDATE: I've tried several things, and currently I have it working partly. I've removed any Django config. Then I've got Wordpress in a /blog/ subdirectory. In there, I have test.php, which just calls phpinfo(), and then also test.html, which shows pure html. When calling test.php, the page loads. However, when I call test.html, or index.php (Wordpress index page), it gives me a 404.

My nGinx config:

server {
        listen   80;

        root /path/to/www/root;


        access_log /path/to/logs/access.log;
        error_log /path/to/logs/error.log;

        location / {
                index index.php;

        location /blog {
                alias /path/to/www/blog;
                try_files $uri =404;
                index index.php index.html;

        location ~ /blog/.+\.php$ {
                include /etc/nginx/fastcgi_params;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /path/to/www/blog$fastcgi_script_name;

        location ~ /\.ht {
                deny all;
share|improve this question

Something like this?

location  /i/ 
{  alias  /spool/w3/images/;

share|improve this answer

You set up a location /blog/ and use all the usual nginx directives to pass off to PHP.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.