如何在 nginx 上的 wsgi 中修复“chdir(): No such file or directory [uwsgi.c line 1723]”?

ADR*_*ADR 9 nginx django

我的主目录中有 treeio 项目,现在我想在 nginx 服务器中运行该 treeio。treeio 已经可以在 Django 自带的源码上独立运行了。我不想在 Django 服务器中运行它,但我想在 nginx 服务器上运行它。我只是按照Karthik 的这个答案中给出的步骤进行操作

但是,在执行或遵循该答案的第 4 步时,它会引发以下错误:

[uWSGI] getting INI configuration from uwsgi.ini
* Starting uWSGI 1.0.3-debian (32bit) on [Thu Jun 27 17:22:01 2013] *
compiled with version: 4.6.3 on 17 July 2012 02:24:04
current working directory: /home/rajesh/treeio
detected binary path: /usr/bin/uwsgi-core
chdir(): No such file or directory [uwsgi.c line 1723]
Run Code Online (Sandbox Code Playgroud)

我的uwsgi.ini文件包含

[uwsgi] 
# set the http port
http = :8080

# change to django project directory
chdir = /home/treeio/

# add /var/www to the pythonpath, in this way we can use the project.app format
pythonpath = /var/www

# set the project settings name
env = DJANGO_SETTINGS_MODULE=treeio.settings

# load django
module = django.core.handlers.wsgi:WSGIHandler()
Run Code Online (Sandbox Code Playgroud)

请帮助我在 nginx 服务器中部署 treeio。

小智 2

chdir 错误消息表明它正在尝试获取不存在的目录。

从显示的输出来看,该 dir 可能是/home/rajesh/treeio/home/treeio/

鉴于该目录已配置为相关的 django 项目目录,它更有可能是/home/treeio/uwsgi.ini但该配置可能仅在您显示的配置中指定。

因此,它很可能存在,因此存在权限问题,因为它/home/treeio/不一定存在。


tek*_*aul 1

一般提示

chdir(): No such file or directory
Run Code Online (Sandbox Code Playgroud)

类型错误。

当错误消息显示“找不到文件”但没有告诉您它正在查找哪个文件时,这很烦人。strace 可以提供帮助,它会打印所有系统调用。

尝试

strace uwsgi --ini uwsgi.ini
Run Code Online (Sandbox Code Playgroud)

输出是神秘的,但在接近末尾的某个地方,它应该告诉我们缺少哪个目录。

在这种情况下可能是/home/treeio/