nginx django uwsgi 页面未找到错误 [英] nginx django uwsgi page not found error

查看:72
本文介绍了nginx django uwsgi 页面未找到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Nginx 上设置 uwsgi 和 Django,但显示页面未找到错误并且错误日志为空.我无法识别错误,因为错误日志为空.

I am trying to setup uwsgi and Django on Nginx but showing page not found error and error logs are empty. I cannot identify the error because the error logs are empty.

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

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

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

uswgi 运行正常,因为我使用以下方法对此进行了测试:

uswgi is running properly because I tested this on following method:

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

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;
        } }

虚拟主机权限:

-rw-r--r-- 1 root root 333 Feb 27 08:54 test.aaaa.com

提前致谢!

推荐答案

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

I did two mistakes One is nginx virtual host configuration and another one is socket permission error

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

要创建套接字存在的空间,您只需选择一个持久目录(例如不是/run 或/tmp)并使 www-data(用户 nginx 运行的身份)成为它的所有者,如下所示:

To create the space for the socket to exist, you just have to pick a persistent directory (e.g. not /run or /tmp) and make www-data (the user nginx runs as) the owner of it, as such:

$ sudo mkdir /var/uwsgi
$ sudo chown www-data:www-data /var/uwsgi

我的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;
    }


}

这篇关于nginx django uwsgi 页面未找到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆