python django uwsgi nginx安装
程序员文章站
2022-05-06 19:07:39
python django uwsgi nginx安装 已安装完成python/django的情况下安装 pip install uwsgi cd /usr/share/nginx/html/ vim uwsgi.ini输入以下内容 #uwsgi.ini file [uwsgi] # Django- ......
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
上一篇: Orico发布首款蓝牙运动音响:防水防震
下一篇: Linux下配置jdk环境
推荐阅读
-
Python的Django框架安装全攻略
-
python django框架中使用FastDFS分布式文件系统的安装方法
-
教你安装python Django(图文)
-
详解Python网络框架Django和Scrapy安装指南
-
详解Django+Uwsgi+Nginx 实现生产环境部署
-
Django uwsgi Nginx 的生产环境部署详解
-
Python、 Pycharm、Django安装详细教程(图文)
-
Django安装和使用---python
-
SLAM+语音机器人DIY系列:(八)高阶拓展——2.centos7下部署Django(nginx+uwsgi+django+python3)
-
详解Django+uwsgi+Nginx上线最佳实战