Nginx:没有这样的文件或目录

2024-04-23 15:13:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个vps服务器,Reg.ru和{}的{}。在

Reg.ru上,我通过dnsadmin添加了domain。好吧。创建注释。状态-synchronized。在

domain的管理面板的freenom上是下一个字段:NameTypeTTLTargetName-空,TTL-3600Type-ATarget-ip服务器。状态-active。在

Nginx公司

/etc/nginx/sites available/myproject/etc/nginx/sites enabled/myproject

server {
  listen 80;
  server_name example.com;
  location = /favicon.ico { access_log off; log_not_found off; }
  location /static/ {
    root /home/myproject;
  }
  location / {
    include proxy_params;
    proxy_pass http://unix:/run/gunicorn.sock;
  }
}

/etc/nginx/nginx.conf公司

^{pr2}$

nginx -t-successful

systemctl status nginx-active

ufw状态

Status: active

To                         Action      From
--                         ------      ----
8000                       ALLOW       Anywhere                  
80                         ALLOW       Anywhere                  
443                        ALLOW       Anywhere                  
8000 (v6)                  ALLOW       Anywhere (v6)             
80 (v6)                    ALLOW       Anywhere (v6)             
443 (v6)                   ALLOW       Anywhere (v6)

当我在浏览器中打开vps-server的ip时,我得到了nginx的主页。在


古尼科恩

/etc/systemd/系统/gunicorn服务

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=root
Group=root
WorkingDirectory=/home/myproject
ExecStart=/home/myproject/myprojectenv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
myproject.wsgi:application
[Install]
WantedBy=multi-user.target

/etc/nginx/sites enabled#cat/etc/systemd/system/套筒

[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target

systemctl status gunicorn-active


Django公司

/home/myproject/myproject/。设置.py

ALLOWED_HOSTS = ['example.com', 'localhost']

DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.postgresql_psycopg2',
         'NAME': 'test_db',
         'USER': 'test_user',
         'PASSWORD': 'test',
         'HOST': 'localhost',
         'PORT': '',
     }
}

我运行一个manage.py runserver,并从Django得到响应,服务器是在^{上启动的。在

但是当我用domain名称打开网站时,我得到了错误:

Unable to access site

Failed to find the IP address of the example.com server.


Tags: 服务器homeserverdomain状态myprojectetcnginx