2017-11-18 239 views
0

在Ubuntu上,我試圖運行三個使用nginx和uwsgi的web應用程序。我能夠使用以下nginx配置運行兩個應用程序,但不能運行第三個應用程序。請幫助我如何運行它。在nginx上運行兩個以上的web應用程序

首先nginx的配置:air-quality.conf

server { 
    listen 80; 
    real_ip_header X-Forwarded-For; 
    set_real_ip_from 127.0.0.1; 
    server_name localhost; 

    location/{ 
     include uwsgi_params; 
     uwsgi_pass unix:/var/www/html/air-quality/socket.sock; 
     uwsgi_modifier1 30; 
    } 

    error_page 404 /404.html; 
    location = /404.html { 
     root /usr/share/nginx/html; 
    } 

    error_page 500 502 503 504 /50x.html; 
    location = /50x.html{ 
     root /usr/share/nginx.html; 
    } 
} 

沒有麻煩,上面的配置制定並表現出對210.123.33.247:80/airData輸出。 第二個nginx配置位於items-rest.conf。它是:

server { 
    listen 81; 
    real_ip_header X-Forwarded-For; 
    set_real_ip_from 127.0.0.1; 
    server_name localhost; 

    location/{ 
     include uwsgi_params; 
     uwsgi_pass unix:/var/www/html/items-rest/socket.sock; 
     uwsgi_modifier1 30; 
    } 

    error_page 404 /404.html; 
    location = /404.html { 
     root /usr/share/nginx/html; 
    } 

    error_page 500 502 503 504 /50x.html; 
    location = /50x.html{ 
    root /usr/share/nginx.html; 
    } 
} 

它還顯示210.123.33.247:81/items上的預期輸出。 但第三個不起作用。配置文件是:

server { 
    list en 8090; 
    real_ip_header X-Forwarded-For; 
    set_real_ip_from 127.0.0.1; 
    server_name localhost; 

    location { 
     include uwsgi_params; 
     uwsgi_pass unix:/var/www/html/display_air/socket.sock; 
     uwsgi_modifier1 30; 
    } 

    error_page 404 /404.html; 
    location = /404.html { 
     root /usr/share/nginx/html; 
    } 

    error_page 500 502 503 504 /50x.html; 
    location = /50x.html{ 
     root /usr/share/nginx.html; 
    } 
} 

在嘗試運行第三方應用,我想sudo systemctl reload nginxsudo systemctl restart nginx。然後,它產生的錯誤說

nginx的:在/etc/nginx/sites-enabled/display-air.conf:7

[EMERG]在 「位置」 指令參數無效號碼是什麼我做錯了嗎?任何人都請幫助我。

回答

0

你在這裏

location { 
    include uwsgi_params; 
    uwsgi_pass unix:/var/www/html/display_air/socket.sock; 
    uwsgi_modifier1 30; 
} 

缺少一個斜槓應該是

location/{ 
    include uwsgi_params; 
    uwsgi_pass unix:/var/www/html/display_air/socket.sock; 
    uwsgi_modifier1 30; 
} 
+0

多麼愚蠢的錯誤。你很棒!你救了我很多痛苦。謝謝你,尼斯。 –

+0

感謝您的幫助,我能夠運行第三個應用程序。但是當我從網絡(210.123.33.247:8090)登錄時,發生內部服務器錯誤。你能猜到爲什麼會發生?當我獨立運行應用程序時,即不通過nginx或uwsgi,它可以正常工作。這意味着該程序沒有錯誤,對嗎?還有什麼可能是這個問題? –

相關問題