8、设置Nginx和uWSGI——Django项目部署到阿里云服

2020-02-18  本文已影响0人  X人格

第一步:安装Nginx和uWSGI

第二步:配置settings.py文件

第三步:配置uWSGI

# 复制以下代码即可
[uwsgi]
socket = 127.0.0.1:8080
chdir = /home/programs/mysite
module = mysite.wsgi
master = ture
processes = 1
threads = 2
max-requests = 2000
chmod-socket = 664
vacuum = ture

stats = %(chdir)/uwsgi/uwsgi.status
pidfile = %(chdir)/uwsgi/uwsgi.pid
daemonize = %(chdir)/uwsgi/uwsgi.log

第四步:配置Nginx

# 复制以下代码即可
 server {
        listen 80;
        server_name localhost;
        charset utf-8;

        location / {
                uwsgi_pass 127.0.0.1:8000;
                include /etc/nginx/uwsgi_params;
        }

        location /static {
                alias /home/programs/collected_static/;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

第五步:启动Nginx和uWSGI

第六步:更新Django项目

上一篇下一篇

猜你喜欢

热点阅读