nginx django uwsgi页面找不到错误



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

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

-rw-r--r-- 1 www-data root 0 2月26日12:31 error.log

USWGI运行正常,因为我在以下方法上对此进行了测试:

uwsgi - -http:8080 - 家庭/家庭/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

预先感谢!

您需要为UWSGI安装Python插件

sudo apt-get install uwsgi-plugin-python

或python 3

sudo apt-get install uwsgi-plugin-python3

您使用此代码的端口8080正在运行项目:

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

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

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

为什么它不起作用。

我犯了两个错误,一个是nginx虚拟主机配置,另一个是套接字许可错误

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

要创建插座存在的空间,您只需要选择一个持久目录(例如,不/运行或/tmp),然后使www-data(用户nginx as as as as y as)的所有者,因此:

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

}

相关内容

最新更新