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.

Sort of an odd question but should be pretty easy to solve. I am developing a Django website right now and the client wants a Wordpress blog as well. Because we're under the gun and have other projects as well, we don't have time to build a nice django blog so we're giving them Wordpress in a subfolder.

I have a lot of experience using Nginx but have never done something like this before, and I'm not very talented with regex.

Here's the structure:

blog (the wordpress blog)
contact
__init__.py
manage.py
settings.py
static (all my static media, htdocs directory)
templates
urls.py
wsgi.py

It's super lightweight thus far, only one single app (contact application). I want domain/blog to hit the /blog/ folder and treat static media like static media, and php files like php files proxying them to my fastcgi process.

And of course I want everything else to work with Django, going to my python fastcgi process.

For the record, everything is working properly except for this nginx config. All my fcgi processes are fine. Here is my nginx config:

# David Simons Website
server {
    listen       80;
    server_name  ********;

    root /usr/local/simons/static;

    index index.html index.php;

    location / {
        fastcgi_pass 127.0.0.1:3033;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param SERVER_NAME $server_name;
        fastcgi_param SERVER_PORT $server_port;
        fastcgi_param SERVER_PROTOCOL $server_protocol;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_pass_header Authorization;
        fastcgi_intercept_errors off;
    }

    location ^~ /static/ {
        alias /usr/local/simons/static/;
    }

    location ^~ /blog/ {
        root /usr/local/simons/;
    }

    location ~* \.php$ {
       fastcgi_pass   127.0.0.1:9000;
       include /etc/nginx/fastcgi.conf;
       fastcgi_param  SCRIPT_FILENAME  /usr/local/simons/$fastcgi_script_name;
    }

    location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
        access_log  off;
        expires 30d;
        break;
    }

}
share|improve this question

1 Answer 1

Why don't you just do

location /blog {
    fastcgi_pass
    etc. 
}
share|improve this answer

Your Answer

 
discard

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