简体   繁体   中英

Nginx php7.4 permission denied

I have stacked with permission denied on my php site. I have tried lot of different configuration but no luck. I am using nginx 1.16, php 7.4 centos. Right now I have disable SELinux and rest configuration:

Nginx runs with user nginx.

Site permissions folders have 775 permissions and files 664. For both of these owner is my user and group is nginx.

Php-fpm: user: myuser, group: nginx, owneruser: nginx, ownergroup: nginx, mode: 0660

I am trying to access a simple test.php file that echoes "hello".

My browser shows a white screen with 404 error and the log files show permission denied.

UPDATE

I tested with a test.html page and still got permission denied so I guess it is not something with php but something with nginx.

Below are excerpts from access and error.log accordingly:

Access log excerpt:

176.92.20.33 - - [17/Dec/2020:06:56:32 +0200] "GET /test.html HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Android 10; Mobile; rv:84.0) Gecko/84.0 Firefox/84.0" "-"

Error Log excerpt:

2020/12/17 06:56:32 [crit] 1152#0: *3 stat() "/home/xxxx/www/test.html" failed (13: Permission denied), client: 176.92.20.33, server: acropolismuseumkids.gr, request: "GET /test.html HTTP/1.1", host: "xxxxx"
2020/12/17 06:56:32 [crit] 1152#0: *3 stat() "/home/xxxxx/www/index.php" failed (13: Permission denied), client: 176.92.20.33, server: xxxxxx, request: "GET /test.html HTTP/1.1", host: "xxxxx"
2020/12/17 06:56:32 [crit] 1152#0: *3 stat() "/home/xxxxx/www/404.html" failed (13: Permission denied), client: 176.92.20.33, server: xxxxxx, request: "GET /test.html HTTP/1.1", host: "xxxxx"
2020/12/17 06:56:32 [crit] 1152#0: *3 stat() "/home/xxxxx/www/404.html" failed (13: Permission denied), client: 176.92.20.33, server: xxxxx, request: "GET /test.html HTTP/1.1", host: "xxxxxx"
2020/12/17 06:56:32 [crit] 1152#0: *3 stat() "/home/xxxxx/www/index.php" failed (13: Permission denied), client: 176.92.20.33, server: xxxxx, request: "GET /test.html HTTP/1.1", host: "xxxxx"

Any help is appreciated.

Well It seems I had made a studipd mistake. I has misstyped the cgi gateway on nginx and php-fpm configuration files. These two should be the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM