Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

Thanks.

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;

        server_name domain.com;

        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_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /path/to/www/blog$fastcgi_script_name;
        }

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

2 Answers 2

Something like this?

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

http://wiki.nginx.org/HttpCoreModule#alias

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

 
discard

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.