1. first install pinax, using the official guide:
and install the necessary packages
apt-get install python-flup nginx subversion python-mysqldb
2. Modify nginx conf
nano /etc/nginx/nginx.conf
user www-data; worker_processes 1; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { worker_connections 1024; # multi_accept on; } http { include /etc/nginx/mime.types; access_log /var/log/nginx/access.log; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; tcp_nodelay on; gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; gzip_comp_level 6; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
3. define foo.com for nginx
nano /etc/nginx/sites-available/foo.com
server {
listen 80;
server_name www.foo.com foo.com;
if ($host != 'foo.com') {
rewrite ^/(.*)$ http://foo.com/$1 permanent;
}
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
fastcgi_pass 127.0.0.1:7718;
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;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
}
location /robots.txt {
alias /www/foo/media/robots.txt;
}
location /site_media/ {
expires 7d;
alias /www/foo/media/;
}
location /media/ {
alias /www/env/lib/python2.6/site-packages/django/contrib/admin/media;
}
}
Boring Symlink:
ln -s /etc/nginx/sites-available/foo.com /etc/nginx/sites-enabled/foo.com
4. Start nginx and fcgi
sudo /etc/init.d/nginx restart python /www/foo/manage.py runfcgi host=127.0.0.1 port=7718 pidfile=/www/foo/foocom.pid maxspare=2
Some useful commands:
If you don’t know where your Python site directory is:
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
Thanks goes to Thinking Critically
No comments:
Post a Comment