2013-10-26 58 views
0

我真的有一个艰难的时间让这个正常工作如何用Django nginx和uwsgi设置多个网站?

在我的站点启用文件夹我有以下两种conf文件设置

站点A(这个网站我设置第一和正常工作):

# the upstream component nginx needs to connect to 
upstream django { 
    server 127.0.0.1:8001; # for a web port socket (we'll use this first) 
    } 

# configuration of the server 
server { 

    # the port your site will be served on 
    listen 80; 
    # the domain name it will serve for 
    server_name databank.eaventures.co www.databank.eaventures.co ; # substitute your mac$ 
    charset  utf-8; 
    access_log /srv/www/*****/logs/access.log; 
    error_log /srv/www/*****/logs/error.log; 

    # max upload size 
    client_max_body_size 75M; # adjust to taste 

    # Django media 
    location /media { 
     alias /srv/www/******/projectdatabank/media; # your Django project's m$ 
    } 

    location /static { 
     alias /srv/www/******/projectdatabank/static; # your Django project's s$ 
    } 

    # Finally, send all non-media requests to the Django server. 
    location/{ 
     uwsgi_pass django; 
     include  /etc/nginx/uwsgi_params; # the uwsgi_params file you installed 
     } 
    } 

站点B(新的网站,我想补充,但没有得到工作):

# the upstream component nginx needs to connect to 
upstream django2 { 
    server 127.0.0.1:8002; # for a web port socket (we'll use this first) 
    } 

# configuration of the server 
server { 
    # the port your site will be served on 
    listen 80; 
    # the domain name it will serve for 
    server_name 50.116.47.120 ***.eaventures.co ; # substitute your machine's IP add$ 
    charset  utf-8; 
    access_log /srv/www/***.capital.com/logs/access.log; 
    error_log /srv/www/***capital.com/logs/error.log; 

    # max upload size 
    client_max_body_size 75M; # adjust to taste 

    # Django media 
    location /media { 
     alias /srv/www/***capital.com/***/media; # your Django project's media$ 
    } 

    location /static { 
     alias /srv/www/***capital.com/***/static; # your Django project's stati$ 
    } 

    # Finally, send all non-media requests to the Django server. 
    location/{ 
     uwsgi_pass django; 
     include  /etc/nginx/uwsgi_params; # the uwsgi_params file you installed 
     } 
    } 

开始uwsgi我RA n个以下命令(实际上我运行一个皇帝的命令,但是我想在这里的时间来解决的一个问题),当我运行这个网站一工作完全没

uwsgi --socket :8001 --chdir /srv/www/.com/projectdatabank/ --wsgi-file /srv/www/.com/projectdatabank/databank/wsgi.py 

现在我运行这个尝试启动站点B

uwsgi --socket :8002 --chdir /srv/www/***capital.com/***/ --wsgi-file /srv/www/***capital.com/***/***/wsgi.py 

当我去到的IP地址(在站点B组),其运行的网站Django应用程序,但在css文件

任何想法不拉?

+0

对不起大家不知道为什么这个选票投下来......让我知道如何更好地提出这个问题 – tareq

回答

2

我得到这个工作,该问题是uwsgi_pass

代替使django的变量,相信连接到上游,我改成了分别为每个文件以下

uwsgi_pass 127.0.0.1:8001; 
uwsgi_pass 127.0.0.1:8002; 
+0

或者你可以设置'uwsgi_pass'到'upstream'组件。例如,你的confs中有2个'upstream'组件:'django'和'django2'。因此,将'uwsgi_pass'分别设置为'django'和'django2'也是可行的。 – xyres