NGINX + PHP-FPM Permission denied

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I have few WordPress websites, all with same config - difference only with user and domain, but got 403 only for newly created virtualhost:

# ref="https://forum.tuteehub.com/tag/c">cat barelef-art.kiev.ua.ref="https://forum.tuteehub.com/tag/c">conf
server {
    server_name barelef-art.kiev.ua;
    aref="https://forum.tuteehub.com/tag/c">cref="https://forum.tuteehub.com/tag/c">cess_log /var/log/nginx/barelef-art.kiev.ua-aref="https://forum.tuteehub.com/tag/c">cref="https://forum.tuteehub.com/tag/c">cess.log;
    error_log /var/log/nginx/barelef-art.kiev.ua-error.log;
    root /var/www/vhosts/barelef_art/barelef-art.kiev.ua;

    loref="https://forum.tuteehub.com/tag/c">cation / {
        index index.php;
    }

    loref="https://forum.tuteehub.com/tag/c">cation ~ \.php$ {
        inref="https://forum.tuteehub.com/tag/c">clude /etref="https://forum.tuteehub.com/tag/c">c/nginx/fastref="https://forum.tuteehub.com/tag/c">cgi_params;
        fastref="https://forum.tuteehub.com/tag/c">cgi_pass  127.0.0.1:9012;
        fastref="https://forum.tuteehub.com/tag/c">cgi_index index.php;
        fastref="https://forum.tuteehub.com/tag/c">cgi_param SCRIPT_FILENAME /var/www/vhosts/barelef_art/barelef-art.kiev.ua$fastref="https://forum.tuteehub.com/tag/c">cgi_sref="https://forum.tuteehub.com/tag/c">cript_name;
    }
}

And also - similar php-fpm ref="https://forum.tuteehub.com/tag/c">configs for few sites:

# ref="https://forum.tuteehub.com/tag/c">cat barelef-art.kiev.ua.ref="https://forum.tuteehub.com/tag/c">conf
[barelef-art.kiev.ua]

listen = 127.0.0.1:9012

listen.allowed_ref="https://forum.tuteehub.com/tag/c">clients = 127.0.0.1

user = barelef_art
group = barelef_art

pm = dynamiref="https://forum.tuteehub.com/tag/c">c
pm.max_ref="https://forum.tuteehub.com/tag/c">children = 20
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1
pm.max_requests = ref="https://forum.tuteehub.ref="https://forum.tuteehub.com/tag/c">com/tag/50">50

slowlog = /var/log/nginx/barelef-art.kiev.ua-slow.log

;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.ref="https://forum.tuteehub.com/tag/c">com
;php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/nginx/barelef-art.kiev.ua-error.log
php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 128M

; Set session path to a ref="https://forum.tuteehub.ref="https://forum.tuteehub.com/tag/c">com/tag/direref="https://forum.tuteehub.com/tag/c">ctory">direref="https://forum.tuteehub.com/tag/c">ctory owned by proref="https://forum.tuteehub.com/tag/c">cess user
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session

php_admin_value[session.save_path] = /var/lib/php/session/barelef_art

User exist:

# id barelef_art
uid=523(barelef_art) gid=523(barelef_art) groups=523(barelef_art)

And virtualhost ref="https://forum.tuteehub.ref="https://forum.tuteehub.com/tag/c">com/tag/direref="https://forum.tuteehub.com/tag/c">ctory">direref="https://forum.tuteehub.com/tag/c">ctory have ref="https://forum.tuteehub.com/tag/c">correref="https://forum.tuteehub.com/tag/c">ct owner:

# ls -l /var/www/vhosts/barelef_art/barelef-art.kiev.ua/
total 192
-rw-r--r--  1 barelef_art barelef_art   418 Deref="https://forum.tuteehub.com/tag/c">c 11 18:59 index.php
-rw-r--r--  1 barelef_art barelef_art 19930 Deref="https://forum.tuteehub.com/tag/c">c 11 18:59 liref="https://forum.tuteehub.com/tag/c">cense.txt
-rw-r--r--  1 barelef_art barelef_art 10691 Deref="https://forum.tuteehub.com/tag/c">c 11 18:59 readme.html
-rw-r--r--  1 barelef_art barelef_art  4951 Deref="https://forum.tuteehub.com/tag/c">c 11 18:59 wp-aref="https://forum.tuteehub.com/tag/c">ctivate.php
...
drwxr-xr-x 12 barelef_art barelef_art  4096 Deref="https://forum.tuteehub.com/tag/c">c 11 18:59 wp-inref="https://forum.tuteehub.com/tag/c">cludes
...

# ls -l /var/lib/php/session/
total 328
drwxr-xr-x 2 barelef_art barelef_art   4096 Deref="https://forum.tuteehub.com/tag/c">c 11 19:06 barelef_art

But when I try open index.php - I got in log:

2014/12/11 20:39:18 [error] 13839#0: *133 "/var/www/vhosts/barelef_art/barelef-art.kiev.ua/index.php" is forbidden (13: Permission denied), ref="https://forum.tuteehub.com/tag/c">client: 37.***.***.56, server: barelef-art.kiev.ua, request: "GET / HTTP/1
.1", host: "barelef-art.kiev.ua"

What I'm doing wrong?

Onref="https://forum.tuteehub.com/tag/c">ce again - same ref="https://forum.tuteehub.com/tag/c">configuration files used for few websites with same CMS, and they works. One of them I added today morning. In evening - added this new - and it's don't work... Seems - I missed something, but - ref="https://forum.tuteehub.com/tag/c">can't understood what and where.

CentOS 6.6, Nginx 1.6.2.

UPD

Adding index.html and open it directly with http://barelef-art.kiev.ua/index.html also returns 403;

ps return correct user for PHP-FPM process:

# ps -eo user:$(ref="https://forum.tuteehub.com/tag/c">cut -d: -f1 /etref="https://forum.tuteehub.com/tag/c">c/passwd | wref="https://forum.tuteehub.com/tag/c">c -L),pid,ppid,ref="https://forum.tuteehub.com/tag/c">c,stime,tname,time,ref="https://forum.tuteehub.com/tag/c">cmd | grep "php-fpm.*barelef" | grep -v grep
barelef_art 14883 14868  0 21:33 ?        00:00:00 php-fpm: pool barelef-art.kiev.ua

# lsof -p 14883 | head
COMMAND   PID        USER   FD   TYPE  DEVICE SIZE/OFF    NODE NAME
php-fpm 14883 barelef_art  ref="https://forum.tuteehub.com/tag/c">cwd    DIR   253,0     4096       2 /
php-fpm 14883 barelef_art  rtd    DIR   253,0     4096       2 /
php-fpm 14883 barelef_art  txt    REG   253,0  3309952 1051669 /usr/sbin/php-fpm
php-fpm 14883 barelef_art  mem    REG   253,0    65928 1709260 /lib64/libnss_files-2.12.so
php-fpm 14883 barelef_art  mem    REG   253,0    83088 1179907 /usr/lib64/php/modules/zip.so

But it seems more NGINX issue...

profilepic.png
manpreet 2 years ago

Check the permissions of directories /var/www/vhosts/barelef_art/barelef-art.kiev.ua/ & /var/www/vhosts/barelef_art/.

When getting forbidden errors in either Nginx or Apache it is always worth working your way back up the tree of directories to ensure the web server can access at each level.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.