一:
下载 uwsgi
tar xf uwsgi-1.9.6.tar.gz
cd uwsgi-1.9.6
python uwsgiconfig.py --build
cp uwsgi /usr/bin/uwsgi
二:
vim /usr/local/services/nginx/uwsgi.ini
[uwsgi]
socket = 0.0.0.0:3001
master = true
pidfile = /usr/local/services/nginx/uwsgi.pid
processes = 8
workers = 2
#project path 项目目录
chdir = /data/django
# 上一级目录
pythonpath = /data/
profiler=true
memory-report=true
enable-threads = true
logdate=true
limit-as=6048
daemonize=/data/django/django.log
启动:uwsgi --ini uwsgi.ini
三:
vim /usr/local/services/nginx/conf/conf.d/django.conf
server {
listen 80;
server_name 10.10.172.10;
index index.php index.html;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3001;
uwsgi_param UWSGI_CHDIR /data/django/; #项目目录
uwsgi_param UWSGI_SCRIPT django_wsgi;
#access_log /data/django/access.log;
}
location ^~ /static {
root /data/django;
}
}
service nginx start
#在生产环境中将
#DEBUG = True
DEBUG = False # 改为 False
#ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['*'] # 改为 '*'
转载于:https://blog.51cto.com/goooood/1711126