django+uwsgi+nginx部署

首先去安装django uwsgi  nginx python

sudo apt-get install nginx
pip install django
pip install uwsgi

安装好后,去配置nginx的文件nginx

server {
    listen  81;
    server_name 47.104.199.225 ;
    charset     utf-8;
    client_max_body_size 75M;
location /static {
        alias /home/appium_ui_test/static;
    }    
location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:9991;
        uwsgi_param UWSGI_PYTHON /usr/bin/python3;
        uwsgi_param UWSGI_CHDIR /home/appium_ui_test/;
 uwsgi_param UWSGI_MODULE manage;    
        uwsgi_param UWSGI_CALLABLE application; 
       
    }
}
/static 这个必须配置,否则一些静态文件会找不到
重启nginx服务
sudo /etc/init.d/nginx restart

而后去配置uwsgidjango

[uwsgi]
chdir=/home/appium_ui_test/
wsgi-file = apptest.wsgi.py
# 指定项目的application
module=apptest.wsgi:application
socket = 127.0.0.1:9991
master = true         //主进程
vhost = true          //多站模式
no-site = true        //多站模式时不设置入口模块和文件
workers = 2           //子进程数
reload-mercy = 10     
vacuum = true         //退出、重启时清理文件
max-requests = 1000   
limit-as = 512
plugins = python3
buffer-size = 30000
pythonpath =/usr/local/lib/python3.5/dist-packages/

再启动你的uwsgiflask

sudo /usr/bin/uwsgi --ini django_uwsgi.ini

 

有几回报错说找不到django但是本身python环境有。app

其实增长一个pythonpath就能够解决socket

增长supervisor管理,当chrash了,能够自动重启

安装后/etc/supervisor/conf.d/ 配置一个文件,以下 简单配置

command=uwsgi /home/flask/flask_blog-python3/helloflask_uwsgi.ini
autostart=ture
autorestart=true
stdout_logfile=/home/flask/flask_blog-python3/uwsgi_supervisor.log
user=root
配置后启动

service supervisor start

终止服务

service supervisor stop

至此,咱们就部署好咱们的django,能够访问了。ui

有问题能够联系我:QQ:952943386 email:leileili126@163.com  qq群:194704520  新群:683894834spa

相关文章
相关标签/搜索