您的位置:首页 > 运维架构 > Nginx

【金】nginx+uwsgi+django+python 应用架构部署

2015-11-12 16:56 796 查看
网上有很多这种配置,但就是没一个靠普的,费了好大的力气才完成架构部署。顺便记录一下。

一.部署前的说明

先安装好python,django,uwsgi,nginx软件后。后配置运行的软件是分先后的。
第一个.配置好django项目的/opt/web/testsite/目录和文件
第二个.配置好uwsgi.ini文件并运行,运行后,会在/opt/web/testsite/目录生成一个tests.sock文件(/opt/web/testsite/tests.sock),用于nginx服务器调用,这就是要uwsgi服务要先于nginx服务器运行的目的。

[uwsgi]

chdir=/opt/web/testsite

module=testsite.wsgi:application


socket=/opt/web/testsite/tests.sock

chmod-socket=666

module=testsite.wsgi


master=true

processes=4

#vhost=true

#no-stie=true

#workers=2

reload-mercy=10

vacuum=true

max-requests=5000

limit-as=1024

#buffer-sizi=30000

pidfile=/var/run/uwsgi.pid

daemonize=/var/log/uwsgi.log


第三个.再设置nginx中的配置文件.我的配置文件是nginx/conf/vhost/www.phalcon.cn.conf文件内容如下

log_formatwww.phalcon.cn'$remote_addr-$remote_user[$time_local]"$request"'

'$status$body_bytes_sent"$http_referer"'

'"$http_user_agent"$http_x_forwarded_for';



server{

listen8088;

#server_namewww.phalcon.cn;

#server_namelocalhost;

server_name_;


access_log/home/wwwlogs/www.phalcon.cn.log;

error_log/home/wwwlogs/error.log;


root/opt/web/testsite;

location/{

uwsgi_passunix:///opt/web/testsite/tests.sock;

includeuwsgi_params;


#uwsgi_pass127.0.0.1:9090;

#uwsgi_paramUWSGI_SCRIPTindex;

#uwsgi_paramUWSGI_PYHOME$document_root;

#uwsgi_paramUWSGI_CHDIR$document_root;


}

access_log/home/wwwlogs/www.phalcon.cn.logwww.phalcon.cn;

}



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: