• Linux 部署 Django 系统


    一:安装uwsgi

      pip3 install uwsgi

    二:进入项目目录下,创建uwsgi.ini配置文件

    [uwsgi]
    # 使用nginx连接时使用功能,上线时才使用socket,指定项目执行的端口号
    socket=127.0.0.1:8000
    # 项目目录
    chdir=/data/webapp/otp_manage
    # 项目中wsgi.py文件的目录,相对于项目目录
    wsgi-file=otp_manage/wsgi.py
    # 最大进程
    workers=3
    # 开启主进程
    master=True
    # 退出、重启时清理文件
    vacuum = true
    #
    pidfile=uwsgi.pid
    daemonize=uwsgi.log  

    三:启动服务

    uwsgi在哪个目录启动,就会在哪个目录生成uwsgi.pid和uswgi.log文件,故需要切换到项目目录下执行
    启动:uwsgi --ini uwsgi.ini
    停止:uwsgi --stop uwsgi.pid
    重启:uwsgi --reload uwsgi.pid
    强制停止:killall -8 uwsgi
    这里我们启动uwsgi服务,可以通过ps -ef | grep uwsgi看到已经有四个uwsgi服务启动。

    四:安装Nginx

    tar zxf nginx-1.8.1.tar.gz 
    cd nginx-1.8.1
    ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre
    make && make install  

    五编写nginx.conf配置文件

    user www www;
    worker_processes 2;
    error_log /usr/local/nginx/logs/nginx_error.log notice;
    pid /usr/local/nginx/sbin/nginx.pid;
    worker_rlimit_nofile 204800;
    events
            {
            use epoll;
            worker_connections 204800;
            }
    http
            {
            include mime.types;
            default_type  application/octet-stream;
            charset utf-8;
            server_tokens off;
            server_names_hash_bucket_size 512;
            client_header_buffer_size 512k;
            large_client_header_buffers 64 512k;
            client_max_body_size 100m;
            proxy_ignore_client_abort on;
            sendfile on;
            tcp_nopush on;
            keepalive_timeout 120;
            keepalive_requests 1024;
            fastcgi_cache_path /usr/local/nginx/fastcgi_cache levels=1:2 keys_zone=TEST:10m inactive=30d max_size=3096m;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 300;
            fastcgi_buffer_size 4k;
            fastcgi_buffers 8 4k;
            fastcgi_busy_buffers_size 8k;
            fastcgi_temp_file_write_size 8k;
    #       fastcgi_cache TEST;
            fastcgi_cache_valid 200 302 1h;
            fastcgi_cache_valid 301 1d;
            fastcgi_cache_valid any 1m;
            fastcgi_cache_min_uses 1;
            fastcgi_cache_use_stale error timeout invalid_header http_500;
            open_file_cache max=204800 inactive=20s;
            open_file_cache_min_uses 1;
            open_file_cache_valid 60s;
            tcp_nodelay on;
            gzip on;
            gzip_min_length 1k;
            gzip_buffers 16 64k;
            gzip_http_version 1.1;
            gzip_comp_level 6;
            gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
            gzip_vary on;
            log_format access '$remote_addr - $remote_user [$time_local] "$request" '
                             '"$status" $body_bytes_sent "$http_referer" '
                             '"$http_user_agent" "$http_x_forwarded_for" '
                             '"$upstream_addr" "$upstream_status" "$request_time" "$upstream_response_time" $bytes_sent $request_length';
    
    include  /usr/local/nginx/conf/vhosts/*.conf;
    }  

    六:创建vhosts目录。编写.conf文件

    server {
            listen       80;
            server_name  localhost;
    
            location / {
                include  uwsgi_params;
                uwsgi_pass  127.0.0.1:8000;
                uwsgi_param UWSGI_SCRIPT otp_manage.wsgi;
                # /data/webapp/otp_manage 是项目目录
                uwsgi_param UWSGI_CHDIR /data/webapp/otp_manage;
    
                index  index.html index.htm;
                client_max_body_size 35m;
            }
          location /static {
              client_max_body_size 35m;
              alias /data/webapp/otp_manage/statics;
          }
    
        }  

    启动Nginx  进行访问即可

  • 相关阅读:
    QTableWidget的使用和美工总结
    pyqt下QTableWidget使用方法小结(转)
    改变QTableWidget 行高(转)
    Qt中 文件对话框QFileDialog 的使用
    Qt:拖拽图片到QLabel上并显示(转)
    Qt获取组合键(转)
    Qt图片显示效率的比较(转)
    QComboBox用法小列(转)
    TinyXML:一个优秀的C++ XML解析器(转)
    JZOJ 3099. Vigenère密码 NOIP2012
  • 原文地址:https://www.cnblogs.com/happlyp/p/10899755.html
Copyright © 2020-2023  润新知