我在alamalinux 9.1中启动了nginx,当我访问该网站时,我得到了404错误,我还在日志文件中发现了一些错误,如2023/05/06 16:14:33 [crit] 248989#248989: *15900 stat() "/root/device_reservation_mgmt/html/index.html" failed (13: Permission denied)
。
也许是我想的/root/device_reservation_mgmt/
问题。所以我用stat
命令测试了它。我也试过chmod 755 /root/device_reservation_mgmt/
,甚至chown -R nginx:nginx /root/device_reservation_mgmt/
,但它没有通过stat
测试。
以下是我尝试的shell日志。
[root@localhost device_reservation_mgmt]# ll /root/device_reservation_mgmt/html/
total 112
-rw-r--r-- 1 root root 644 May 6 16:11 _app.config.js
drwxr-xr-x 2 root root 61440 May 6 16:11 assets
-rw-r--r-- 1 root root 894 May 6 16:11 favicon.ico
-rw-r--r-- 1 root root 2893 May 6 16:11 index.html
-rw-r--r-- 1 root root 1311 May 6 16:11 index.html.gz
-rw-r--r-- 1 root root 7367 May 6 16:11 logo.png
drwxr-xr-x 4 root root 32 May 6 16:11 resource
[root@localhost device_reservation_mgmt]#
[root@localhost device_reservation_mgmt]# chown -R nginx:nginx /root/device_reservation_mgmt/html/
[root@localhost device_reservation_mgmt]#
[root@localhost html]# ll
total 112
-rw-r--r-- 1 nginx nginx 644 May 6 16:11 _app.config.js
drwxr-xr-x 2 nginx nginx 61440 May 6 16:11 assets
-rw-r--r-- 1 nginx nginx 894 May 6 16:11 favicon.ico
-rw-r--r-- 1 nginx nginx 2893 May 6 16:11 index.html
-rw-r--r-- 1 nginx nginx 1311 May 6 16:11 index.html.gz
-rw-r--r-- 1 nginx nginx 7367 May 6 16:11 logo.png
drwxr-xr-x 4 nginx nginx 32 May 6 16:11 resource
[root@localhost html]# cd ..
[root@localhost device_reservation_mgmt]#
[root@localhost device_reservation_mgmt]# sudo -u nginx stat /root/device_reservation_mgmt/html
stat: cannot statx '/root/device_reservation_mgmt/html': Permission denied
[root@localhost device_reservation_mgmt]#
[root@localhost ~]# sudo -u nginx stat /root/device_reservation_mgmt
stat: cannot statx '/root/device_reservation_mgmt': Permission denied
[root@localhost ~]#
[root@localhost ~]# sudo -u nginx stat /root/
File: /root/
Size: 4096 Blocks: 16 IO Block: 4096 directory
Device: fd00h/64768d Inode: 100663361 Links: 59
Access: (0550/dr-xr-x---) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2023-05-06 16:21:16.188246512 +0800
Modify: 2023-05-06 16:18:10.295282579 +0800
Change: 2023-05-06 16:18:10.295282579 +0800
Birth: 2020-02-11 13:12:10.898000000 +0800
[root@localhost ~]#
[root@localhost ~]# ll -d device_reservation_mgmt/
drwxr-xr-x. 8 nginx nginx 247 May 6 16:21 device_reservation_mgmt/
[root@localhost ~]# ll -d /root
dr-xr-x---. 59 root root 4096 May 6 16:18 /root
[root@localhost ~]#
[root@localhost ~]# chmod a+x /root/device_reservation_mgmt/
[root@localhost ~]#
[root@localhost ~]# stat --format '%a' /root
550
[root@localhost ~]# stat --format '%a' /root/device_reservation_mgmt/
755
[root@localhost ~]#
[root@localhost ~]# chmod 550 /root/device_reservation_mgmt/
[root@localhost ~]# sudo -u nginx stat /root/device_reservation_mgmt/
stat: cannot statx '/root/device_reservation_mgmt/': Permission denied
[root@localhost ~]#
[root@localhost device_reservation_mgmt]# cp -r html/ /opt/html
[root@localhost device_reservation_mgmt]# sudo -u root stat /opt/html
File: /opt/html
Size: 132 Blocks: 0 IO Block: 4096 directory
Device: fd00h/64768d Inode: 2325445 Links: 4
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2023-05-06 16:28:50.883780094 +0800
Modify: 2023-05-06 16:28:51.318794001 +0800
Change: 2023-05-06 16:28:51.318794001 +0800
Birth: 2023-05-06 16:28:50.883780094 +0800
[root@localhost device_reservation_mgmt]#
1条答案
按热度按时间piah890a1#
我发现问题了,可能是
/root
的other
权限没有x
位。同时也要注意
stat
的位置和cwd对stat
结果的影响。