我写得很烂,还是看这个吧
http://djangobook.py3k.cn/chapter20/
如果你希望你的Django以FastCGI的方式运行,那么你还必须安装 flup 这个Python库,http://www.djangoproject.com/r/flup/ 获取他们的最新的SVN版本。
apt-get install fabric
apt-get install python-flup
apt-get install mercurial
apt-get install rcconf
apt-get install python-ldap
apt-get install memcached
apt-get install python-memcache
获取帮助python manage.py runfcgi help
参考
http://hi.baidu.com/crafter/blog/item/d2c26aaebd012cc57dd92ab8.html
http://djangobook.py3k.cn/chapter20/还是需要好好看看啊
-------------------
ubuntu+fcgi+nginx+django
django版本太高不行,1.4就不行,换1.2.3
原理就是python启动fcgi指定端口8088
nginx开启端口80,并监听8088
缺什么就apt-get install python-什么
root@homehao:/etc/nginx# nginx -v
nginx version: nginx/0.8.54
root@homehao:/etc/nginx# django-admin.py --version
1.2.3
日志在/var/log/nginx或/var/log/httpd
#/bin/sh
#echo "更新源代码"
#svn update -r $1
killall python
echo "服务关闭"
kill `cat fcgi.pid`
echo "服务重启"
cd /opt/www/myapp
python manage.py runfcgi method=threaded host=127.0.0.1 port=8088 --settings=settings maxchildren=300 pidfile=/opt/www/myapp /fcgi.pid
在/etc/nginx/或其他地方存在nginx.conf的位置修改
worker_processes 8;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
include myapp.conf;
}
引入myapp.conf
内容为
server{
listen 80;
server_name cas.sina.google.com;
access_log /var/log/httpd/access.log;
location /server-status {
stub_status on;
access_log off;
allow 10.0.0.0/9;
allow 192.168.0.0/16;
deny all;
}
location /static/ {
root /opt/www/myapp/;
}
location / {
# host and port to fastcgi server;
fastcgi_pass 127.0.0.1:8088;
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_param REMOTE_ADDR $remote_addr;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_intercept_errors off;
fastcgi_connect_timeout 120;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
}