2013-10-26 87 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