1. 程式人生 > >centos7.3部署django用uwsgi和nginx[未解決]

centos7.3部署django用uwsgi和nginx[未解決]

開始 centos index host mit localhost centos7.3 var span

現在nginx

uwsgi

django

都已經完成完畢,那麽開始

uwsgi 配置

uwsgi支持ini、xml等多種配置方式,本文以 ini 為例, 在/etc/目錄下新建blog.ini,添加如下配置:

[uwsgi]
socket = 127.0.0.1:9090
master = true         //主進程
vhost = true          //多站模式
no-site = true        //多站模式時不設置入口模塊和文件
workers = 2           //子進程數
reload-mercy = 10     
vacuum = true         //退出、重啟時清理文件
max-requests = 1000 limit-as = 512 buffer-size = 30000 pidfile = /var/run/uwsgiblog.pid //pid文件,用於下面的腳本啟動、停止該進程 daemonize = /var/www/python/uwsgiblog.log

Nginx 配置

找到nginx的安裝目錄(如:/usr/local/nginx/),打開conf/nginx.conf文件,修改server配置:

server {
        listen       80;
        server_name  localhost;
        
        location 
/ { include uwsgi_params; uwsgi_pass 127.0.0.1:9090; //必須和uwsgi中的設置一致 uwsgi_param UWSGI_SCRIPT demosite.wsgi; //入口文件,即wsgi.py相對於項目根目錄的位置,“.”相當於一層目錄 uwsgi_param UWSGI_CHDIR /demosite; //項目根目錄 index index.html index.htm; client_max_body_size 35m; } }

設置完成後,在終端運行:

uwsgi --ini /etc/blog.ini 
service nginx restart

centos7.3部署django用uwsgi和nginx[未解決]