linux服务器nginx搭载多个pyton语言的web

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/antch620/article/details/88691115

一、假设nginx的安装目录为/usr/local/nginx

搭载多个web站点,在安装目录下新建一个文件夹vhost,路径为:/usr/local/nginx/vhost

该文件下存放不同web的配置,再次只写一个,其他雷同

server {

        # 监控端口,对于nginx的web站点,可以相同,nginx依据路径区分访问的web
        listen       8002;
        server_name  localhost;

        #charset koi8-r;    
    charset     utf-8;

        #access_log  logs/host.access.log  main;
    access_log      /var/log/nginx/exampleA_access.log;
    error_log       /var/log/nginx/exampleA_error.log;


    location / {

            include      uwsgi_params;

            uwsgi_pass 127.0.0.1:8089;      #与uwsgi.ini保持一致    

     }

    location /static/ {

              alias  /var/www/html/exampleA/static/;

             index  index.html index.htm;

        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

二、nginx.conf的配置(路径为/usr/local/nginx/conf)


#user  nobody;
worker_processes  1;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

# 加载不同web的配置
    include /usr/local/nginx/vhost/*.conf;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {

# 假设服务器上同时运行apache,nginx避开80端口
        listen       8001;
    }

}

二、下面附加django的uwsgi的配置。

[uwsgi]
# 项目根目录路径(full path)
chdir           = /var/www/html/exampleA
# Django的 wsgi 文件
module          = exampleA.wsgi
master          = true
# 最大工作进程数(CPU密集型建议设为CPU核心数,IO密集型建议设为CPU核心数的两倍)
processes       = 4
# unix套接字文件路径
socket          =:8089
# 退出时清空环境
vacuum          = true
#每个进程开启4个线程
threads         = 2
#支持线程启动
enable-threads  = True
#设置uwsgi后台运行
daemonize = /var/www/html/exampleA/uwsgi.log

猜你喜欢

转载自blog.csdn.net/antch620/article/details/88691115