美文网首页
mint下nginx和uwsgi部署django

mint下nginx和uwsgi部署django

作者: jhs1873 | 来源:发表于2017-05-01 22:05 被阅读0次

参考:

http://www.cnblogs.com/fnng/p/5268633.html

安装Nginx

apt-get install nginx

启动Nginx:

/etc/init.d/nginx start  #启动

/etc/init.d/nginx stop  #关闭

/etc/init.d/nginx restart  #重启


修改Nginx默认端口号

打开/etc/nginx/sites-enabled

listen 8088 default_server;

listen [::]:8088 default_server;

其中8088 自定义端口号

安装uwsgi

1.升级pip

pip install --upgrade pip

2.安装setuptools

pip install setuptools

3.安装python-dev

apt-get install python-dev

4.安装uwsgi

pip install uwsgi

安装django

pip install django

部署django

1.项目下创建配置文件myweb_uwsgi.ini

修改代码uwsgi重载:添加

py-autoreload=1

2.项目下

uwsgi --ini myweb_uwsgi.ini

3.修改/etc/nginx/sites-enabled/default

8099自定义端口

4.重启nginx


错误问题解决:


参考:

http://www.cnblogs.com/94cool/p/5952219.html

安装supervisor并设置自启动(实现自启动uwsgi)

apt-get install supervisor

/etc/supervisor/conf.d/目录下新建XX.conf

——————

[program:myweb]

command=uwsgi --ini myweb_uwsgi.ini

directory=/home/js/myweb

user=www-data

——————

命令行下:

touch /var/run/supervisor.sock

chmod 777 /var/run/supervisor.sock

service supervisor restart

————————

实现自启动

修改/lib/systemd/system/supervisor.service

_______________________

[Unit]

Description=Supervisor daemon

[Service]

Type=forking

ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf

ExecStop=/usr/bin/supervisorctl shutdown

ExecReload=/usr/bin/supervisorctl reload

KillMode=process

Restart=on-failure

RestartSec=42s

[Install]

WantedBy=multi-user.target

_______________________

systemctl enable supervisor

验证一下是否为开机启动:

systemctl is-enabled supervisor

相关文章

网友评论

      本文标题:mint下nginx和uwsgi部署django

      本文链接:https://www.haomeiwen.com/subject/ebfftxtx.html