Django nginx Debian
- How to make a simple install of django onto small Debian-6 VPS.
- I’ll stick with flup, which enables python to serve fastcgi and some
- other protocols.
- I use it in conjunction with nginx, which in turn is used save memory.
Literature:
- http://library.linode.com/using-linux/administration-basics#system_diagnostics
- http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/
http://www.mindinmotion.ru/post/django-postgresql-nginx-on-debian-server
1 upgrade the system
apt-get upgrade
2 install required dependencies
apt-get install nginx-light postgresql python-django python-psycopg2 python-flup python-imaging
3 configure nginx
you may want to use emacs, vim, or nano. in case of last - you should read how to configure nano better.
server { server_name report.loc; location / { root /var/www/siteyour/www; fastcgi_pass 127.0.0.1:3434; include /usr/local/nginx/fastcgi.conf; } location /media { alias /var/www/siteyour/www/uploads; } location /admin-media { alias /usr/share/pyshared/django/contrib/admin/media; } } //here you should notice the difference between nginx alias and root // while testing, you may remove default entry and add a directive `listen 80` right // after the opening server brace
and fastcgi.conf
fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param QUERY_STRING $query_string; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_pass_header Authorization; fastcgi_intercept_errors off;
4 postgres
su postgres createdb yoursite createuser youruser nano /etc/postgresql/9.0/main/pg_hba.conf
modify one of the last lines to use `trust` instead of `ident`-based authentication
/etc/init.d/postgresql restart
6 troubles
you may issue a 403 error on your static files. that’s not getting fixed with chmod 0777 ./*. You just have to
groupadd site useradd -g site site chown site /path/to/yoursitedir
and change the first line of nginx.conf to
user site site;
7 run python
manage.py runfcgi method=threaded host=127.0.0.1 port=3434
8 restart nginx
/etc/init.d/nginx restart
*9 copy your files
scp -r yorsitedir login@addr:path
this will create yourdir inside the path on the addr host
That’s it! Comment if you experience any troubles!
- ** few more links on nginx:
- http://greenmice.info/ru/node/115 http://greenmice.info/ru/node/116
Category: administration, Debian, django, nginx
Comments