nginx部署django项目

安装nginx

> rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
> yum -y install nginx

安装uwsgi

pip3 install uwsgi

配置nginx

server {
       listen       99.99.99.250:7000 ssl;
        server_name  nac.innotechx.com:7000;
        ssl_certificate /opt/key/server.pem;      // 证书配置
        ssl_certificate_key /opt/key/server.key;   // 证书配置
        ssl_session_timeout  20m;
        ssl_protocols  SSLv2 SSLv3 TLSv1;
        ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_prefer_server_ciphers   on;
        root         /usr/share/nginx/html;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
        location / {
           proxy_pass   http://127.0.0.1:8001/;   #用来和uWSGI进行通讯的
           proxy_redirect off;
           proxy_set_header        Host    $host;
           proxy_set_header        REMOTE_ADDR     $remote_addr;
           proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
           real_ip_recursive on;
           proxy_max_temp_file_size 0;
           proxy_connect_timeout      90;
           proxy_send_timeout         90;
           proxy_read_timeout         90;
           proxy_buffer_size          4k;
           proxy_buffers              4 32k;
           proxy_busy_buffers_size    64k;
           proxy_temp_file_write_size 64k;
        }

使用uwsgi启动django项目

/usr/local/bin/uwsgi --http-socket 127.0.0.1:8001 --chdir /opt/pfcode/pfauto/  --wsgi-file /opt/pfcode/pfauto/PFAuto/wsgi.py --master --processes 2 --threads 2 --threads 2 --daemonize /var/log/uwsgi.log
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。