Nginx 打开()&引用;失败(2:没有这样的文件或目录)
当我请求链接时Nginx 打开()&引用;失败(2:没有这样的文件或目录),nginx,nginx-location,Nginx,Nginx Location,当我请求链接时http://abc.example.com/images/default-thumbnail.jpg查看日志文件输出时发生404错误[error]1244#0:*1 open()“/tmp/upload dir/images/default thumbnail.jpg”失败(2:没有这样的文件或目录), 但事实上,这个文件就在那里,权威机构是777 [root@localhost nginx]# ll /tmp/upload-dir/images/default-thumbnai
http://abc.example.com/images/default-thumbnail.jpg
查看日志文件输出时发生404错误[error]1244#0:*1 open()“/tmp/upload dir/images/default thumbnail.jpg”失败(2:没有这样的文件或目录),
但事实上,这个文件就在那里,权威机构是777
[root@localhost nginx]# ll /tmp/upload-dir/images/default-thumbnail.jpg
-rwxrwxrwx 1 root root 7592 6月 21 2016 /tmp/upload-dir/images/default-thumbnail.jpg
Nginx配置:
server {
charset utf-8;
client_max_body_size 128M;
sendfile off;
listen 80;
server_name abc.example.com;
access_log /www/abc/logs/nginx-access.log;
error_log /www/abc/logs/nginx-error.log;
root /tmp/upload-dir;
location /images/ {
autoindex on;
expires 30d;
}
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
}
正如Terrence所说:Nginx别名路径不能是临时路径。例如:/tmp/**您还应该检查周围目录的权限。
/tmp/upload dir
权限是drwxrwx 4 nginx nginx 4096年4月22日10:15 upload dir
,我真的想不出哪里没有权限,我使用根用户启动nginx您是否使用具有附加安全策略的操作系统,例如CentOS/SELinux?我找到了原因,指向路径的根点不能在临时目录中。谢谢你的回答,我已经处理了这个问题。我已经尝试了4个多小时,只是为了发现我不能对文件使用/tmp
。谢谢你救了我剩下的时间:)