Total Pageviews

Thursday, 8 December 2011

Transifex + Django + nginx on Ubuntu vps

 from http://michaelshadle.com/2009/11/01/transifex-django-nginx-on-ubuntu

You can probably also use this for just Django + nginx on Ubuntu too, it should work the same for any Django-based package, just change the Transifex-specific stuff (like /site_media and such.)
Dependencies:
  • python-django package from Ubuntu (currently Jaunty's 1.0.2-1ubuntu0.1)
  • Transifex installed to /home/transifex/web/transifex, from source
  • Transifex setup to answer over fastcgi on port 8080
  • Tested on nginx 0.7.x and 0.8.x compiled from source
/etc/nginx/nginx.conf:
01server {
02   listen 80;
03   server_name foo.com;
04   include /etc/nginx/confs/defaults.conf;
05   location / {
06      fastcgi_pass 127.0.0.1:8080;
07      include /etc/nginx/confs/django.conf;
08   }
09   location /site_media {
10      root /home/transifex/web/transifex;
11      include /etc/nginx/confs/expires.conf;
12   }
13   location /media {
14      root /usr/share/python-support/python-django/django/contrib;
15      include /etc/nginx/confs/expires.conf;
16   }
17}
/etc/nginx/confs/defaults.conf:
01location ~ /\.ht {
02   deny all;
03}
04 
05location ~ \.svn {
06   deny all;
07}
08 
09log_not_found off;
10server_name_in_redirect off;
/etc/nginx/confs/django.conf:
03fastcgi_param PATH_INFO $fastcgi_script_name;
04fastcgi_param REQUEST_METHOD $request_method;
05fastcgi_param QUERY_STRING $query_string;
06fastcgi_param SERVER_NAME $server_name;
07fastcgi_param SERVER_PORT $server_port;
08fastcgi_param SERVER_PROTOCOL $server_protocol;
09fastcgi_param CONTENT_TYPE $content_type;
10fastcgi_param CONTENT_LENGTH $content_length;
11fastcgi_pass_header Authorization;
12fastcgi_intercept_errors off;
/etc/nginx/confs/expires.conf:
1location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
2   expires max;
3   access_log off;
4}                                                                

No comments:

Post a Comment