Nginx stat() 失败(13:权限被拒绝)
Nginx stat() failed (13: Permission Denied)
好的,之前有一些帖子对此进行了发布,但没有解决方案可以解决我的问题。
我已经配置了网站,直接 HTML、CSS & JS,我正在尝试添加一个 wordpress 网站。我的wordpress站点配置如下。
#######################
server {
listen 80;
root /usr/share/nginx/threadtheatre/wordpress;
index index.php;
server_name threadtheatre.co.uk;
access_log /var/log/nginx/thread.access.log;
error_log /var/log/nginx/thread.error.log;
location / {
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
这是我日志中的错误
"/usr/share/nginx/threadtheatre/wordpress/index.php" failed (13: Permission denied), client: 109.155.53.189, server: threadtheatre.co.uk, request: "GET / HTTP/1.1", host: "threadtheatre.co.uk"
nginx 正在使用 nginx 用户,php-fpm 也是如此。 nginx目录及其所有子目录具有以下权限。
drwxrwxr-x. 3 root nginx 4096 Feb 8 18:23 ..
如果我在网络上浏览 threadtheatre.co.uk,我会收到 404。
希望有人能帮助解决这个问题。
李.
您是否已使用 -R 授予权限?
chown -R nginx /usr/share/nginx/threadtheatre/wordpress/
chmod -R 644 /usr/share/nginx/threadtheatre/wordpress/
你还有这个问题吗?这个解释对我有用:
https://serverfault.com/a/170263/140684
基本上 nginx 需要对您的应用程序路径上的每个目录具有执行权限。希望这有帮助。
对我来说,这是因为启用了 selinux,请查看
selinuxenabled && echo enabled || echo disabled
如果启用尝试禁用
nano /etc/sysconfig/selinux
SELINUX=disabled
然后
reboot
如果 nginx
托管在 Fedora
或 RedHat
上,更改 SELinux
政策并允许 nginx
从路径 /home/path/site
chcon -R -t httpd_sys_content_t /home/path/site
好的,之前有一些帖子对此进行了发布,但没有解决方案可以解决我的问题。
我已经配置了网站,直接 HTML、CSS & JS,我正在尝试添加一个 wordpress 网站。我的wordpress站点配置如下。
#######################
server {
listen 80;
root /usr/share/nginx/threadtheatre/wordpress;
index index.php;
server_name threadtheatre.co.uk;
access_log /var/log/nginx/thread.access.log;
error_log /var/log/nginx/thread.error.log;
location / {
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
这是我日志中的错误
"/usr/share/nginx/threadtheatre/wordpress/index.php" failed (13: Permission denied), client: 109.155.53.189, server: threadtheatre.co.uk, request: "GET / HTTP/1.1", host: "threadtheatre.co.uk"
nginx 正在使用 nginx 用户,php-fpm 也是如此。 nginx目录及其所有子目录具有以下权限。
drwxrwxr-x. 3 root nginx 4096 Feb 8 18:23 ..
如果我在网络上浏览 threadtheatre.co.uk,我会收到 404。
希望有人能帮助解决这个问题。
李.
您是否已使用 -R 授予权限?
chown -R nginx /usr/share/nginx/threadtheatre/wordpress/
chmod -R 644 /usr/share/nginx/threadtheatre/wordpress/
你还有这个问题吗?这个解释对我有用: https://serverfault.com/a/170263/140684
基本上 nginx 需要对您的应用程序路径上的每个目录具有执行权限。希望这有帮助。
对我来说,这是因为启用了 selinux,请查看
selinuxenabled && echo enabled || echo disabled
如果启用尝试禁用
nano /etc/sysconfig/selinux
SELINUX=disabled
然后
reboot
如果 nginx
托管在 Fedora
或 RedHat
上,更改 SELinux
政策并允许 nginx
从路径 /home/path/site
chcon -R -t httpd_sys_content_t /home/path/site