在Ubuntu 9.10下配置基于Nginx的django站点

1. 安装

sudo apt-get install Python-django python-flup nginx

2.修改nginx配置文件

sudo vim /etc/nginx/nginx.conf

细节见这里:http://articles.slicehost.com/2008/5/15/Ubuntu-hardy-nginx-configuration

3.创建虚拟主机(for django)

sudo vim /etc/nginx/sites-available/foo.com

输入以下文字:

server {
listen 80;
server_name foo.com;

access_log /home/foo/public_html/foo/log/access.log;
error_log /home/foo/public_html/foo/log/error.log;

location / {
# host and port to fastcgi server
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;
}
}

然后建立link:

sudo ln -s /usr/local/nginx/sites-available/foo.com /usr/local/nginx/sites-enabled/foo.com

4. 启动djangosite, nginx
python /home/mitnk/public_html/foo/manage.py runfcgi host=127.0.0.1 port=7718
sudo /etc/init.d/nginx start

相关推荐