找不到nginx Django uwsgi页面

2024-10-01 13:45:08 发布

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

我试图在Nginx上设置uwsgi和Django,但显示页面未找到错误,错误日志为空。 我无法识别错误,因为错误日志是空的。在

错误日志/var/log/nginx/error.log

-rw-r--r-- 1 www-data root 0 Feb 26 12:31 error.log

在uswgi上正确运行此方法是因为:

uwsgi --http :8080 --home /home/flybegins/python/django/venv/ --chdir /home/flybegins/python/django/sample -w sample.wsgi

virtual host 

    server {
        listen 80;
        server_name test.aaaaaaa.com;
        error_log  /var/log/nginx/error.log
        location /static/ {
            root /home/flybegins/python/django/sample/
        }

        location / {
            include         uwsgi_params;
            uwsgi_pass      unix:/home/flybegins/python/django/sample/sample.sock;
        } }

虚拟主机权限:

^{pr2}$

提前谢谢!在


Tags: sampledjangologhomeservervar错误nginx
3条回答

您正在使用端口8080运行项目,代码如下:

uwsgi  http :8080  home /home/flybegins/python/django/venv/  chdir /home/flybegins/python/django/sample -w sample.wsgi

您正尝试使用此配置将NGINX绑定到不存在的套接字文件:

^{pr2}$

这就是为什么它不起作用。在

您需要为uwsgi安装python插件

sudo apt-get install uwsgi-plugin-python

或者对于python 3

^{pr2}$

我犯了两个错误一个是nginx虚拟主机配置,另一个是socket权限错误

uWSGI配置

[uwsgi]
project = prd
base = /home/flybegins/python/django

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

master = true
processes = 5

gid = www-data
uid = www-data

socket = /var/uwsgi/%(project).sock
chmod-socket = 664
vacuum = true

要创建套接字存在的空间,只需选择一个持久目录(例如not/run或/tmp)并将www data(nginx的用户运行方式)设为其所有者,如下所示:

^{pr2}$

我的nginx虚拟主机配置

server {
    listen 80;
    server_name testserver1.com;
    access_log /home/flybegins/log/python/testserver1.com/access.log;
    error_log /home/flybegins/log/python/testserver1.com/error.log error;

 location  /static {
      alias  /home/flybegins/python/django/prd/static_files/;
    }

  location / {
        include         uwsgi_params;
        uwsgi_pass      unix:/var/uwsgi/prd.sock;
    }


}

相关问题 更多 >