安装
pip install django==2.1
pip install uwsgi
yum -y install nginx
uwsgi环境变量
ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi
测试
#启动
uwsgi --http 0.0.0.0:80 --file Transient/wsgi.py --static-map=/static=static
#停止
netstat -lnp|grep 8000
kill -9 进程号
--http 这个就和runserver一样指定IP 端口
--file 这个文件就里有一个反射,如果你在调用他的时候没有指定Web Server就使用默认的
-- static 做一个映射,指定静态文件
配置uwsgi.ini
[uwsgi]
http = 127.0.0.1:8080
chdir = /var/www/Transient
module = Transient.wsgi
socket=/tmp/uwsgi.sock
master = true
processes = 4
threads = 2
enable-threads = True
daemonize = /var/log/uwsgi.log
buffer-size = 21573
vacuum = true
uid=root
gid=root
static-map=/static=/var/www/Transient/static
验证uwsgi配置
[root@VM_0_5_centos Transient]# uwsgi --ini uwsgi.ini
[uWSGI] getting INI configuration from uwsgi.ini
[uwsgi-static] added mapping for /static => /var/www/Transient/static
配置nginx配置文件
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server {
#listen 80;
listen 443 ssl;
server_name localhost;
#charset koi8-r;
charset utf-8;
ssl_certificate /var/www/Transient/ssl/weapp.crt;
ssl_certificate_key /var/www/Transient/ssl/weapp.key;
location / {
include uwsgi_params;
uwsgi_connect_timeout 30;
uwsgi_pass unix:/tmp/uwsgi.sock;
index index.html index.htm;
client_max_body_size 75M;
}
sendfile on;
keepalive_timeout 65;
}
}