2017-06-18 100 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; 并重新启动你的液滴或服务器。