码迷,mamicode.com
首页 > 编程语言 > 详细

python django uwsgi nginx安装

时间:2019-05-06 14:24:20      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:type   RKE   stream   log   directory   col   may   height   ssi   

python django uwsgi nginx安装
已安装完成python/django的情况下安装
pip install uwsgi
cd /usr/share/nginx/html/
vim uwsgi.ini输入以下内容-------------------------------------------------------------
#uwsgi.ini file
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /usr/share/nginx/html #manage.py所以目录
# Django‘s wsgi file
module = project2.wsgi:application #应用程序project2下的wsgi文件
# the virtualenv (full path)
#home = /path/to/virtualenv
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 3
# the socket (use the full path to be safe)
#socket = /home/myself/myself.sock
socket = 127.0.0.1:8000 #以8000端口提供socket服务
# ... with appropriate permissions - may be needed
chmod-socket = 666
chown-socket = nginx:nginx
# clear environment on exit
vacuum = true
enable-threads = true
运行为cd /usr/share/nginx/html/
uwsgi --ini ./uwsgi.ini
yum install nginx
cd /etc/nginx/
vim nginx.conf输入以下内容-------------------------------------------------------------
upstream django {
server 127.0.0.1:8000;
}
location /static/ {
root /usr/share/nginx/html;
}
location / {
include uwsgi_params;
uwsgi_pass django;
}
cd /etc/systemd/system/ vim uwsgi.service
[Unit]
Description=uWSGI Emperor
After=syslog.target
[Service]
ExecStart=/usr/bin/uwsgi --emperor /usr/share/nginx/html
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
setting.py中加入
STATIC_ROOT = ‘/usr/share/nginx/html/static/‘
python manage.py collectstatic
systemctl restart uwsgi.service
systemctl restart nginx.service
systemctl enable uwsgi.service
systemctl enable nginx.service

python django uwsgi nginx安装

标签:type   RKE   stream   log   directory   col   may   height   ssi   

原文地址:https://www.cnblogs.com/pyvm/p/10819293.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!