原创博文地址:django进阶04部署上线(nginx,uwsgi,supervisor)
django自身服务ok
python manage.py runserver,验证可正常访问
uwsgi安装和服务验证
安装:pip Install uwsgi
测试代码
uwsgi –plugin python –http :8001 –wsgi-file test.py
redirect_stderr = true ; 把 stderr 重定向到 stdout,默认 false
stdout_logfile_maxbytes = 20MB ; stdout 日志文件大小,默认 50MB
stdout_logfile = /data/log/plantool_stdout.log
stderr_logfile = /data/log/plantool_err.log
#daemonize=/var/log/uwsgi8011.log # 守护进程一定要注释掉(关键)
启用config配置:supervisord -c /etc/supervisord.conf
supervisorctl status //查看所有进程的状态
supervisorctl stop es //停止es
supervisorctl start es //启动es
supervisorctl restart es //重启es
supervisorctl update //配置文件修改后使用该命令加载新的配置
supervisorctl reload //重新启动配置中的所有程序
user www-data #nginx -t 测试通过,启动后访问权限不足
user nobody # nginx -t 测试不通过,
user john # nginx -t 测试不通过,(john无root权限,无法启动nginx,但是templates目录拥有者)
user yyyy # nginx -t 测试不通过,(yyyy有root权限,且是nginx服务启动者)
删除:user 这一行 # nginx -t 测试通过,启动后访问权限不足
user work john # nginx -t 测试不通过,
user work yyyy # nginx -t 测试不通过,
user john work # nginx -t 测试通过,启动后访问ok
chmod -R 777 /data
chmod -R 777 /data/www/
python manage collectstatic # 自动收集静态文件到django_setting配置的STATIC_ROOT中
cp STATIC_ROOT templates/static
chmod -R 777 xxx
`
参考
linux下部署Django uwsgi: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory:/erhangboke/p/11673156.html
初次使用uwsgi:no python application found, check your startup logs for errors:/loveyangaddddd/p/8119720.html
uWSGI出现错误:no python application found, check your startup logs for errors:/weixin_40576010/article/details/89000128
supervisor管理uwsgi:/supery007/p/9368242.html
Django 部署(Nginx):/django/django-nginx-deploy.html
使用supervisor作为uWSGI的守护进程:/post/f04c0_242345
Supervisor使用详解:/p/0b9054b33db3
解决Nginx出现403 forbidden (13: Permission denied)报错的四种方法:/williamjie/p/9604594.html
nginx 错误集锦:/p/3de849802a89
Nginx之proxy_pass指令url反斜杠作用:/sleepIII/article/details/100787652