建议:FreeBSD RELENG_6
使用心得:nginx处理大并发比较稳定,特别省内存,配置简单.
1.安装python
cd /usr/ports/lang/python
make install clean
2.安装flup
cd /usr/ports/www/py-flup
make install clean
3.安装django 1)
cd /usr/ports/www/py-django
make install clean
4.安装nginx
cd /usr/ports/www/nginx
make install clean
5.启动和管理flup的脚本 参考http://docs.djangoproject.com/en/1.0/howto/deployment/fastcgi/
5.1prefork方式
#!/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
5.2threaded方式
/usr/local/bin/python manage.py runfcgi method=threaded host=127.0.0.1 port=3033
6.配置nginx 参考http://wiki.codemongers.com/Main
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
6.1prefork方式
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)$ {
root /home/www/django/test_tmdxy_org/media/;
access_log off;
}
}
6.2threaded方式
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 127.0.0.1:3033;
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)$ {
root /home/www/django/test_tmdxy_org/media/;
access_log off;
}
}
7.配置反向代理服务器
只需在server {}里加入
location /go/ {
proxy_pass http://192.168.1.5:8088/;
proxy_redirect http://192.168.1.5:8088/ /;
}
8.nginx+django推荐打的补丁 http://code.djangoproject.com/ticket/8874
主要解决,nginx+django,访问/的时候,无法正确映射到django的方法的问题.
分享到:
相关推荐
django-on-docker 这是使用Nginx,Gunicorn和PostgreSQL在Docker上构建Django环境的示例。用法Git克隆$ git clone git@github.com:dsonoda/django-on-docker.git建立开发环境目标使用docker-compose在单个主机上设置...
使用Postgres,Gunicorn和Nginx对Django进行Docker化是否想学习如何构建? 查看 。要使用这个项目吗?发展历程使用默认的Django开发服务器。 将.env.dev-sample重命名为.env.dev 。 更新docker-compose.yml和.env....
django-on-docker:Django + Postgresql + Gunicorn + LetsEncrypt + Nginx
在 Digital Ocean 中使用 nginx 和 gunicorn 部署 Django 的 Fabric 集合 可用命令: command Send custom command with args or not. Usag... create_package Create virtualenv create_...
Docker上的Django,postgresql,gunicorn,nginx Django-python网络框架PostgreSQL-数据库管理Gunicorn-WSGI服务器(“绿色独角兽”)(Django使用WSGI规范)NGINX- 网络服务器 (来自entrypoint.sh)要从db中删除...
代理网站uwsgi部分报错问题提示:本教程仅用于Ubuntu18.04 ,其它系统版本可能不成功环境搭建搭建环境介绍Ubuntu18.04系统(root权限)+Nginx+uwsgi+Python3.6+Django本项目使用VENV虚拟环境进行部署环境搭建更新APT...
爬虫服务器使用Django编译,代码位于文件夹下,CGI系统使用纯请求拉取数据,AIS系统由于有recaptcha2,使用请求和Selenium/ xdotool混合模式拉取数据(感谢 ) 前端服务器采用nginx部署,使用python和爬虫服务器进行...
Django最佳实践与部署:Nginx + Gunicorn + Supervisor(Ubuntu和CentOS) http://sfdye.com/articles/django-best-practice-and-deployment-with-nginx-gunicorn-and-supervisor/ 结果出现runserver –settings=…...
相关性: NGINX: ://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04 码头工人: : Docker Compose: : Certbot: ://certbot.eff.org/lets-encrypt/ubuntubionic-nginx....
用Flask, Tornado, Nginx等进行网络开发 Flask is minimal and simple. You don’t get ORM’s, Admin Panels and other stuff that Django has out of the box. You can install a very cool admin panel with just...
作为后端开发者,你需要掌握以下关键知识: ...5. 后端框架和库:熟悉一些常用的后端框架和库,如Spring(Java)、Django(Python)、Ruby on Rails(Ruby)等,以加快开发速度并提供常用功能和组件。 . . .
X CodeIgniter CoffeeScript ColdFusion Common Lisp Compass Cordova Corona CSS D3.js Django Dojo Toolkit Drupal Elixir Emacs Lisp Ember.js Emmet.io Erlang Express.js Expression Engine ExtJS Flask ...
Apache、NginX、MS IIS PHP、ASP.NET、Django、Ruby on Rails、Java 一旦检测到平台,就可以测试一些特定的漏洞 尝试在 Apache mod_rewrite(通过 413 错误)或 mod_negotiation 下获取真实路径,检查服务器状态...