nginx+uwsgi+django+ssl

安装

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;
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值