2017-06-18 46 views
0

我在網上尋找解決方案,但沒有任何幫助。 我想在我的服務器上部署一個指向vps.florisdeboer.com的django項目。我已經閱讀了一些教程,並完成了他們告訴我的內容,但502錯誤一直在顯示。-nginx,uwsgi,502域名上的網關不正確

我有所有重要的文件,如果你錯過了什麼,請評論,而我可以發佈它作爲編輯。

好吧,讓我們開始吧:

projectname是webshop。沒什麼特別的,只是在django中建立一個網上商店。我使用db.sqlite3作爲我的數據庫。

的/ etc/uwsgi /網站

[uwsgi]  
project = webshop 
uid = floris 
base = /home/%(uid) 

chdir = %(base)/%(project) 
home = %(base)/BIT/ 
module = %(project).wsgi:application 

master = true 
processes = 5 

socket = /run/uwsgi/%(project).sock 
chown-socket = %(uid):www-data 
chmod-socket = 660 
vacuum = true 

plugins=python27 

的/ etc/nginx的/

server { 
    listen 80; 
    server_name florisdeboer.com vps.florisdeboer.com; 

    location = /favicon.ico { access_log off; log_not_found off; } 
    location /static/ { 
     root /home/floris/webshop; 
    } 

    location/{ 
     include   uwsgi_params; 
     uwsgi_pass  unix:/run/uwsgi/website.sock; 
    } 
} 

而且sudo systemctl status uwsgi

● uwsgi.service - uWSGI Emperor service 
    Loaded: loaded (/etc/systemd/system/uwsgi.service; enabled; vendor preset: enabled) 
    Active: active (running) since Sat 2017-06-17 22:13:00 CEST; 17h ago 
Main PID: 24782 (uwsgi) 
    Status: "The Emperor is governing 1 vassals" 
    CGroup: /system.slice/uwsgi.service 
      ├─24782 /usr/local/bin/uwsgi --emperor /etc/uwsgi/sites 
      ├─24785 /usr/local/bin/uwsgi --ini webshop.ini 
      ├─24788 /usr/local/bin/uwsgi --ini webshop.ini 
      ├─24789 /usr/local/bin/uwsgi --ini webshop.ini 
      ├─24790 /usr/local/bin/uwsgi --ini webshop.ini 
      ├─24791 /usr/local/bin/uwsgi --ini webshop.ini 
      └─24792 /usr/local/bin/uwsgi --ini webshop.ini 

Jun 18 15:54:21 srvrfloris systemd[1]: Started uWSGI Emperor service. 
Jun 18 15:57:20 srvrfloris systemd[1]: Started uWSGI Emperor service. 
Jun 18 15:58:18 srvrfloris systemd[1]: Started uWSGI Emperor service. 
Warning: Journal has been rotated since unit was started. Log output is incomplete or una was started. Log output is incomplete or unavailable. 

這裏是同同樣的命令啓用了站點,但爲nginx

● nginx.service - A high performance web server and a reverse proxy server 
    Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) 
    Active: active (running) since Sun 2017-06-18 15:54:13 CEST; 14min ago 
Main PID: 882 (nginx) 
    CGroup: /system.slice/nginx.service 
      ├─882 nginx: master process /usr/sbin/nginx -g daemon on; master_process on 
      └─883 nginx: worker process       

Jun 18 15:54:13 srvrfloris systemd[1]: Starting A high performance web server and a revering A high performance web server and a reverse proxy server... 

Jun 18 15:54:13 srvrfloris systemd[1]: nginx.service: Failed to read PID from file /run/n.service: Failed to read PID from file /run/nginx.pid: Invalid argument 

Jun 18 15:54:13 srvrfloris systemd[1]: Started A high performance web server and a reversed A high performance web server and a reverse proxy server. 

~ 

錯誤日誌從root $ uwsgi --ini /etc/uwsgi/sites/webshop.ini

[uWSGI] getting INI configuration from /etc/uwsgi/sites 
*** WARNING: Can't find section "uwsgi" in INI configuration file /etc/uwsgi/sites *** 
*** Starting uWSGI 2.0.15 (64bit) on [Sun Jun 18 23:08:20 2017] *** 
compiled with version: 5.4.0 20160609 on 17 June 2017 21:30:14 
os: Linux-4.4.0-66-generiC#87-Ubuntu SMP Fri Mar 3 15:29:05 UTC 2017 
nodename: srvrfloris 
machine: x86_64 
clock source: unix 
detected number of CPU cores: 1 
current working directory: /home/floris 
detected binary path: /usr/local/bin/uwsgi 
!!! no internal routing support, rebuild with pcre support !!! 
uWSGI running as root, you can use --uid/--gid/--chroot options 
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** WARNING: you are running uWSGI without its master process manager *** 
your processes number limit is 3826 
your memory page size is 4096 bytes 
detected max file descriptor number: 1024 
lock engine: pthread robust mutexes 
thunder lock: disabled (you can enable it with --thunder-lock) 
The -s/--socket option is missing and stdin is not a socket. 

我希望有人能幫助我!

乾杯,

弗洛里斯

+0

%(base)/%(project)的權限是什麼?和「/ run/uwsgi」dirs? – Tamar

+0

'drwxr-xr-x 2 floris www-data 40 Jun 18 16:16/run/uwsgi' for/run/uwsgi –

+0

'drwxrwxr-x 7 floris floris 4096 Jun 17 21:27/home/floris/webshop' for/home/floris/webshop –

回答

1

如果問題是實際的。該行中的 將網站更改爲網上商店unix:/run/uwsgi/website.sock; 並重新啓動你的液滴或服務器。