On 1/10/2010 11:48, bruno desthuilliers wrote:

> This is fine when using the dev server, but what when you will serve
> your static files directly from the frontend web server ?

Hi Bruno,

to answer your question, i'll post the relevant parts of configs.
I use apache with the wsgi module, nginx for the static files and also
memcached to speed up so parts (but this is not relevant for this)
Here are my configs.

I make a dns entry for the project (dashboard) and 1 for the app
(calltracking). If i would make a new app for the dashboard, i'll have
to make a new dns entry and offcourse make a specific settings_app.py file,
and a nginx.conf "server" config.
Also, i'll need to make a media template tag relevant for the project.

I've tested this and it works and i don't see any flaws as to why it
shouldn't work for more apps.

======== settings.py ========
...
ADMIN_MEDIA_PREFIX = 'http://dashboard:88/media/admin/'
MEDIA_URL = 'http://dashboard:88/media'
...
from  settings_calltracking import *


======== settings_calltracking.py ========
...
CALLTRACKING_MEDIA_URL = 'http://calltracking:88/media/calltracking'
...

======== dashboard.wsgi ========
import sys
import os

sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
sys.path = [
    'C:/Programs/django_svn/trunk',
    'C:/Code/sitesdjango/dashboard/trunk',
    'C:/Code/sitesdjango/dashboard/trunk/dashboard' ] + sys.path

os.environ['DJANGO_SETTINGS_MODULE'] = 'dashboard.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


======== apache's vhost..conf ========
...
<VirtualHost *:80>
    ServerAdmin me
    ServerName dashboard
    DocumentRoot "C:/Code/sitesdjango/dashboard/trunk/dashboard"
    LogLevel warn
    WSGIScriptAlias / 
"C:/Code/sitesdjango/dashboard/trunk/dashboard/dashboard.wsgi"
</VirtualHost>
...

======== nginx.conf ========
worker_processes  1;
error_log  logs/error.log;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  logs/access.log  main;
    sendfile        on;
    tcp_nopush     on;

    server {
        listen       88;
        server_name  dashboard;
        root C:/Code/sitesdjango/dashboard/trunk/dashboard;
        access_log  logs/host.access.log  main;
        error_log logs/appname-error.log;

        location /media/admin {
            autoindex on;
            root   C:/Code/sitesdjango/calltracking/trunk/calltracking;
        }
        location /media {
            autoindex on;
            root   C:/Code/sitesdjango/dashboard/trunk/dashboard/media;
        }
        location ~* 
^.+\.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg)$
 {
            access_log off;
            break;
        }
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|bmp|js)$ {
            expires 30d;
            break;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

    server {
        listen       88;
        server_name  calltracking_local;
        root C:/code/sitesdjango/dashboard/trunk/dashboard/calltracking;
        access_log  logs/host.access.log  main;
        error_log logs/appname-error.log;

        location /media/calltracking {
            autoindex on;
            root   
C:/Code/sitesdjango/dashboard/trunk/dashboard/calltracking/media/calltracking;
        }
        location ~* 
^.+\.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg)$
 {
            access_log off;
            break;
        }
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|bmp|js)$ {
            expires 30d;
            break;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to