nginx 以及 uwsgi 的配置

cat /etc/nginx/nginx.conf

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
         listen       80;
        server_name  localhost;


        #charset koi8-r;
        #access_log  /var/log/nginx/host.access.log  main;
        access_log      /var/log/nginx/myweb_access.log;
         error_log       /var/log/nginx/myweb_error.log;


        client_max_body_size 75M;


        location / {
            include uwsgi_params;
            #这行指定uwsgi开放的数据交换接口
            uwsgi_pass 127.0.0.1:8090;
            #这里与配置uwsgi的ini文件中module内容一致
            uwsgi_param UWSGI_SCRIPT ibook.wsgi;
            #这里与配置uwsgi的ini文件中chdir内容一致
            uwsgi_param UWSGI_CHDIR  /root/ibook;
        }

        location ^~ /static/ {
            root /root/ibook/;
            #这行指定静态文件的搜索目录, localhost/static/test.css => /home/ibook/static/test.css
            #注意,这里location行中指定的地址也会在转换后的地址中
        }
    }

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}

start_proj.ini

# start_proj.ini file
[uwsgi]

# Django-related settings

# uwsgi的对外socket接口,nginx将通过该接口与uwsgi做数据交换,因为与nginx同在一个服务器内,不需要在防火墙上对端口8090做访问许可

socket = 127.0.0.1:8090

# the base directory (project full path)

# 本项记录Django对象工程的完整路径

chdir = /root/ibook

# Django s wsgi file

# 本项指示uwsgi.py文件的位置,其位于Django工程目录下有个与工程名同名的子文件夹内 ( 设置方式为   文件夹名.wsgi )

module = ibook.wsgi

# process-related settings
# master
master  = true

# maximum number of worker processes
processes = 4

# ... with appropriate permissions - may be needed
# chmod-socket= 664
# clear environment on exit
vacuum= true
# pidfile for record run pid
pidfile=pid.uwsgi
# run process background and save log to daemonize
daemonize = UWSGI.log

运行

uwsgi --ini  start_proj.ini
pkill -f -9 uwsgi

原文地址:https://www.cnblogs.com/sea-stream/p/14182287.html