Chinaunix首页 | 论坛 | 博客
  • 博客访问: 19270037
  • 博文数量: 7460
  • 博客积分: 10434
  • 博客等级: 上将
  • 技术积分: 78178
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-02 22:54
文章分类

全部博文(7460)

文章存档

2011年(1)

2009年(669)

2008年(6790)

分类: BSD

2008-03-23 20:44:48

使用心得:nginx处理大并发比较稳定,特别省,配置简单.
1.安装python
cd /usr/ports/lang/python
install clean

2.安装flup

cd /usr/ports/www/py-flup
make install clean

3.安装

cd /usr/ports/www/py-django
make install clean

4.安装

cd /usr/ports/www/nginx
make install clean

5.启动和管理flup的脚本 参考http://www.djangoproject.com/documentation/fastcgi/

#!/bin/sh
# Replace these three settings.
PROJDIR="/home/user/myproject"
PIDFILE="$PROJDIR/mysite.pid"
SOCKET="$PROJDIR/mysite.sock"
cd $PROJDIR
if [ -f $PIDFILE ]; then
kill `cat -- $PIDFILE`
rm -f -- $PIDFILE
fi
exec /usr/local/bin/python manage.py runfcgi method=prefork socket=${SOCKET} pidfile=${PIDFILE} minspare=5 maxspare=10 maxchildren=40

6.配置nginx 参考
nginx.conf

user  www www;
worker_processes 5;
pid /var/run/nginx.pid;
error_log /var/log/httpd/error.log warn;
events {
worker_connections 10240;
use kqueue;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 4 2k;
request_pool_size 4k;
output_buffers 4 32k;
postpone_output 1460;
sendfile on;
tcp_nopush on;
keepalive_timeout 75 20;
tcp_nodelay on;
client_max_body_size 10m;
client_body_buffer_size 256k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
client_body_temp_path /var/log/nginx/client_body_temp;
proxy_temp_path /var/log/nginx/proxy_temp;
fastcgi_temp_path /var/log/nginx/fastcgi_temp;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain text/html application/x-javascript text/xml text/css;
ignore_invalid_headers on;
include website.conf;
}

website.conf

server {
listen 80;
server_name test.tmdxy.org;
access_log /var/log/httpd/access.log main;
location / {
# host and port to fastcgi server
fastcgi_pass unix:/tmp/test_tmdxy.sock;
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;
}
location ^~ /media/ {
alias /home/www/django/test_tmdxy_org/meida/;
}
location ~* ^.+\.(gif|png|jpg|jpeg|css|swf|htm|html|asp|php|jsp|js|doc|txt)$ {
/home/www/django/test_tmdxy_org/media/;
access_log off;
}
}

7.配置反向
只需在server {}里加入

location /go/ {
proxy_pass
proxy_redirect /;
}
阅读(1297) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~