无法确定我的配置问题在哪里。我有运行Django项目的DigitalOcean VPS。 我配置了Gunicorn和Nginx。 设置正确的IP地址。 检查了gunicorn状态(ok)。
/var/log/nginx/error.log
NGinx仍然显示默认页面而不是Django项目主页。
甚至已从default
删除了sites-enabled
,仍然看到nginx
默认页面。
gunicorn.service
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=django
Group=www-data
WorkingDirectory=/home/django/nameofmyproject
ExecStart=/home/django/nameofmyproject/nameofmyprojectvenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/django/nameofmyproject/nameofmyproject.sock nameofmyproject.wsgi:application
[Install]
WantedBy=multi-user.target
站点可用/ nameofmyproject
server {
listen 80;
server_name <my_ip_address>;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/django/nameofmyproject;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/django/nameofmyproject/nameofmyproject.sock;
}
}
gunicorn状态
unicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2017-10-19 09:56:18 UTC; 1min 2s ago
Main PID: 1372 (gunicorn)
Tasks: 4
Memory: 138.0M
CPU: 3.971s
CGroup: /system.slice/gunicorn.service
├─1372 /home/django/nameofmyproject/nameofmyprojectvenv/bin/python /home/django/nameofmyproject/nameofmyprojectvenv/bin/gunicorn --access-logfile - --work
├─1555 /home/django/nameofmyproject/nameofmyprojectvenv/bin/python /home/django/nameofmyproject/nameofmyprojectvenv/bin/gunicorn --access-logfile - --work
├─1556 /home/django/nameofmyproject/nameofmyprojectvenv/bin/python /home/django/nameofmyproject/nameofmyprojectvenv/bin/gunicorn --access-logfile - --work
└─1557 /home/django/nameofmyproject/nameofmyprojectvenv/bin/python /home/django/nameofmyproject/nameofmyprojectvenv/bin/gunicorn --access-logfile - --work
Oct 19 09:56:18 ubuntu-16 systemd[1]: Started gunicorn daemon.
Oct 19 09:56:21 ubuntu-16 gunicorn[1372]: [2017-10-19 09:56:21 +0000] [1372] [INFO] Starting gunicorn 19.7.1
Oct 19 09:56:21 ubuntu-16 gunicorn[1372]: [2017-10-19 09:56:21 +0000] [1372] [INFO] Listening at: unix:/home/django/nameofmyproject/nameofmyproject
Oct 19 09:56:21 ubuntu-16 gunicorn[1372]: [2017-10-19 09:56:21 +0000] [1372] [INFO] Using worker: sync
Oct 19 09:56:21 ubuntu-16 gunicorn[1372]: [2017-10-19 09:56:21 +0000] [1555] [INFO] Booting worker with pid: 1555
Oct 19 09:56:21 ubuntu-16 gunicorn[1372]: [2017-10-19 09:56:21 +0000] [1556] [INFO] Booting worker with pid: 1556
Oct 19 09:56:22 ubuntu-16 gunicorn[1372]: [2017-10-19 09:56:21 +0000] [1557] [INFO] Booting worker with pid: 1557
真的不知道问题出在哪里。如何调试?
答案 0 :(得分:1)
确保您执行了以下操作