laravel – 403 nach Änderung des Nginx-Standard-Webverzeichnisses unter CentOS 7.2
仅有的幸福
仅有的幸福 2017-05-16 16:49:48
0
2
721

In CentOS 7.2 wurde die offizielle Yum-Quelle von Nginx hinzugefügt und Nginx/1.10.2 mit Yum Install Nginx installiert Eine weitere Konfigurationsdatei für den virtuellen Host. Der Inhalt lautet wie folgt:

server {
        listen 80;
        server_name idas.it;
        root /home/html;
        index index.html index.php;
#       location / {
#               try_files $uri $uri/ /index.php?$query_string;
#       }
        location ~ \.php$ {
                fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}

Verzeichnisberechtigungen sind wie folgt:

[root@hrms /]# ll && cd /home && ll && cd html && ll
total 84
dr-xr-xr-x.  17 root root  4096 Nov 12 13:39 .
dr-xr-xr-x.  17 root root  4096 Nov 12 13:39 ..
lrwxrwxrwx.   1 root root     7 Nov 12 11:37 bin -> usr/bin
dr-xr-xr-x.   5 root root  4096 Nov 12 12:16 boot
drwxr-xr-x.  20 root root  3260 Nov 12 13:10 dev
drwxr-xr-x.  83 root root  8192 Nov 12 14:40 etc
drwxr-xr-x.   5 root root    78 Nov 12 15:27 home
lrwxrwxrwx.   1 root root     7 Nov 12 11:37 lib -> usr/lib
lrwxrwxrwx.   1 root root     9 Nov 12 11:37 lib64 -> usr/lib64
drwxr-xr-x.   2 root root     6 Aug 12  2015 media
drwxr-xr-x.   2 root root     6 Aug 12  2015 mnt
drwxr-xr-x.   2 root root     6 Aug 12  2015 opt
dr-xr-xr-x. 137 root root     0 Nov 12 13:10 proc
-rw-r--r--.   1 root root 43092 Nov 12 13:11 .readahead
dr-xr-x---.   6 root root  4096 Nov 12 15:23 root
drwxr-xr-x.  24 root root   680 Nov 12 15:31 run
lrwxrwxrwx.   1 root root     8 Nov 12 11:37 sbin -> usr/sbin
drwxr-xr-x.   2 root root     6 Aug 12  2015 srv
dr-xr-xr-x.  13 root root     0 Nov 12 13:10 sys
drwxrwxrwt.  10 root root  4096 Nov 12 15:31 tmp
drwxr-xr-x.  13 root root  4096 Nov 12 11:37 usr
drwxr-xr-x.  20 root root  4096 Nov 12 13:38 var
total 12
drwxr-xr-x.  5 root  root    78 Nov 12 15:27 .
dr-xr-xr-x. 17 root  root  4096 Nov 12 13:39 ..
-rw-r--r--.  1 root  root  1097 Oct 19 00:35 default.conf
drwxrwxr-x.  2 root  root    23 Nov 12 15:24 html
drwxr-xr-x.  5 mysql mysql 4096 Nov 12 14:22 mysql
drwxrwxr-x.  2 nginx nginx    6 Nov 12 14:41 php
total 4
drwxrwxr-x. 2 root root  23 Nov 12 15:24 .
drwxr-xr-x. 5 root root  78 Nov 12 15:27 ..
-rwxrwxr-x. 1 root root 612 Nov 12 15:24 index.html

Die Berechtigungen sind erteilt, aber der Zugriff ist immer noch 403 Verboten. Das Folgende ist das Fehlerprotokoll von Nginx:

2016/11/12 15:31:28 [error] 17524#17524: *2 "/home/html/index.html" is forbidden (13: Permission denied), client: 10.120.9.254, server: idas.it, request: "GET / HTTP/1.1", host: "idas.it"
2016/11/12 15:39:28 [error] 17524#17524: *3 "/home/html/index.html" is forbidden (13: Permission denied), client: 10.120.9.254, server: idas.it, request: "GET / HTTP/1.1", host: "idas.it"
2016/11/12 15:39:29 [error] 17524#17524: *3 "/home/html/index.html" is forbidden (13: Permission denied), client: 10.120.9.254, server: idas.it, request: "GET / HTTP/1.1", host: "idas.it"

Warum kann bei gleicher Berechtigungskonfiguration normal auf das Verzeichnis /var/share/nginx/html zugegriffen werden, andere Verzeichnisse haben jedoch keine Berechtigungen?

[root@hrms html]# ps aux | grep nginx
nginx    17292  0.0  0.1 650776 10504 ?        S    14:50   0:00 php-fpm: pool www
nginx    17293  0.0  0.1 650776 10500 ?        S    14:50   0:00 php-fpm: pool www
nginx    17294  0.0  0.1 650776 10500 ?        S    14:50   0:00 php-fpm: pool www
nginx    17295  0.0  0.1 650776 10500 ?        S    14:50   0:00 php-fpm: pool www
nginx    17296  0.0  0.1 650776 10504 ?        S    14:50   0:00 php-fpm: pool www
root     17523  0.0  0.0  47792  1164 ?        Ss   15:31   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    17524  0.0  0.0  48184  2184 ?        S    15:31   0:00 nginx: worker process
root     17617  0.0  0.0 112648   964 pts/0    S+   16:19   0:00 grep --color=auto nginx

Ich habe später den Besitzer und die Benutzergruppe von /home, Unterverzeichnissen und Dateien auf nginx gesetzt, aber es wurde immer noch 403 Verboten angezeigt und das Fehlerprotokoll war immer noch dasselbe!

Bitte bitten Sie den erfahrenen Fahrer, Ihnen den Weg zu weisen! ! ! ! !

仅有的幸福
仅有的幸福

Antworte allen(2)
大家讲道理

可以试试是否是SElinux没关导致的,可以使用如下命令关闭:

setenforce 0
世界只因有你

好像跟什么安全策略有关,通过软连接应该可以解决,ln -s /var/nginx/html /home/html

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!