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.
Related
I have a Laravel 7 project on the Ubuntu + Nginx server. I can upload files less than ~10mb, but when i am trying to upload a 120mb file I got an error. I am already changed memory_limit, upload_max_filesize, post_size to 640mb in php.ini. It did not help. I am also restart php-fpm and nginx services.
ERROR LOG
2021/01/21 21:11:51 [warn] 13069#13069: *1 a client request body is
buffered to a temporary file /var/lib/nginx/body/0000000001, client: 92.47.198.158, server: servername, request: "POST /courseclass/17 HTTP/2.0", host: "servername", referrer: "https://servername/courseclass/17"
2021/01/21 21:11:53 [error] 13069#13069: *1 openat() "/var/www/servername/video/class/video_course_1611240590.mp4" failed (2: No such file or directory), client: 92.47.198.158, server: servername, request: "GET /video/class/video_course_1611240590.mp4 HTTP/2.0", host: "servername", referrer: "https://servername/watch/course/6"
2021/01/21 21:11:54 [error] 13069#13069: *1 openat() "/var/www/servername/video/class/video_course_1611240590.mp4" failed (2: No such file or directory), client: 92.47.198.158, server: servername, request: "GET /video/class/video_course_1611240590.mp4 HTTP/2.0", host: "servername", referrer: "https://servername/watch/course/6"
2021/01/21 21:41:18 [error] 13069#13069: *8 openat() "/var/www/servername/images/light.jpg" failed (2: No such file or directory), client: 92.47.149.211, server: servername, request: "GET /images/light.jpg HTTP/2.0", host: "servername", referrer: "https://servername/"
2021/01/21 21:41:21 [error] 13069#13069: *8 openat() "/var/www/servername/images/light.jpg" failed (2: No such file or directory), client: 92.47.149.211, server: servername, request: "GET /images/light.jpg HTTP/2.0", host: "servername", referrer: "https://servername/"
2021/01/21 21:49:53 [warn] 13069#13069: *10 an upstream response is
buffered to a temporary file /var/lib/nginx/fastcgi/3/00/0000000003 while reading upstream, client: 92.47.198.158, server: servername, request: "POST /courseclass/17 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/servername.sock:", host: "servername",
referrer: "https://servername/courseclass/17"
The problem was in the less memory of the server. After I increase it from 5GB to 10GB there is no problems. But before that there was about 200MB and I tried to upload a video of 100MB
I have done a fresh installation of WordPress on AWS Elastic BeanStalk.
I am not using the root directory. I have moved the WordPress code to the public directory.
I am not able to open the page to add or edit the post/page.
I am getting the below error in Nginx logs.
I tried both WordPress 5.5.3 and 5.4.4
Any clue where the issue can be?
2020/12/04 12:24:47 [warn] 13851#0: *65 an upstream response is buffered to a temporary file /var/lib/nginx/tmp/fastcgi/8/00/0000000008 while reading upstream, client: 103.5.133.148, server: , request: "GET /wp-admin/post-new.php?post_type=page HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock:", host: "blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com", referrer: "http://blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com/wp-admin/upload.php"
2020/12/04 12:24:48 [error] 13851#0: *68 open() "/var/www/html/public/wp-includes/js/dist/vendor/wp-polyfill.min.js" failed (2: No such file or directory), client: 103.5.133.148, server: , request: "GET /wp-includes/js/dist/vendor/wp-polyfill.min.js?ver=7.4.4 HTTP/1.1", host: "blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com", referrer: "http://blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com/wp-admin/post-new.php?post_type=page"
2020/12/04 12:24:48 [error] 13851#0: *69 open() "/var/www/html/public/wp-includes/js/dist/vendor/lodash.min.js" failed (2: No such file or directory), client: 103.5.133.148, server: , request: "GET /wp-includes/js/dist/vendor/lodash.min.js?ver=4.17.15 HTTP/1.1", host: "blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com", referrer: "http://blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com/wp-admin/post-new.php?post_type=page"
2020/12/04 12:24:49 [error] 13851#0: *68 open() "/var/www/html/public/wp-includes/js/dist/vendor/react.min.js" failed (2: No such file or directory), client: 103.5.133.148, server: , request: "GET /wp-includes/js/dist/vendor/react.min.js?ver=16.9.0 HTTP/1.1", host: "blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com", referrer: "http://blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com/wp-admin/post-new.php?post_type=page"
2020/12/04 12:24:49 [error] 13851#0: *69 open() "/var/www/html/public/wp-includes/js/dist/vendor/react-dom.min.js" failed (2: No such file or directory), client: 103.5.133.148, server: , request: "GET /wp-includes/js/dist/vendor/react-dom.min.js?ver=16.9.0 HTTP/1.1", host: "blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com", referrer: "http://blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com/wp-admin/post-new.php?post_type=page"
2020/12/04 12:24:49 [error] 13851#0: *72 open() "/var/www/html/public/wp-includes/js/dist/vendor/moment.min.js" failed (2: No such file or directory), client: 103.5.133.148, server: , request: "GET /wp-includes/js/dist/vendor/moment.min.js?ver=2.22.2 HTTP/1.1", host: "blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com", referrer: "http://blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com/wp-admin/post-new.php?post_type=page"
The issue was caused by git. I am using composer with WordPress, so had added the 'vendor/' entry in the .gitignore file.
Because of this none of the vendor folders were getting shipped to the server and hence the missing files.
I changed 'vendor/' to '/vendor' in .gitignore file. Ran 'git rm -r --cached .' and committed the code again.
It works now.
My system OS is MacOS10.13. The default PHP version is 7.1.16.
I use phpbrew to manage the PHP version. And I installed the php5.6.When I use command phpbrew switch php5.6. Then I use the commandphp -v
Then it outputs:
PHP 5.6.30 (cli) (built: May 14 2019 18:30:16)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
Then I use the commandphp-fpm -v
output:
PHP 7.1.16 (fpm-fcgi) (built: Mar 31 2018 03:00:16)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
The php version in terminal is php5.6, and in the web, the version is php7.1
The php-fpm default path is in /usr/sbin.
When I try to replace the php-fpm, the web page is 404. The nginx error.log is in here.
2019/05/15 18:35:48 [error] 3125#0: *51 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
2019/05/15 18:35:48 [error] 3125#0: *51 open() "/usr/local/Cellar/nginx/1.15.12/html/50x.html" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
2019/05/15 18:35:48 [error] 3125#0: *51 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
2019/05/15 18:35:48 [error] 3125#0: *51 open() "/usr/local/Cellar/nginx/1.15.12/html/50x.html" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
ailed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
2019/05/15 18:48:03 [error] 3125#0: *64 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
2019/05/15 18:48:03 [error] 3125#0: *64 open() "/usr/local/Cellar/nginx/1.15.12/html/50x.html" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:82"
I want to use php5.6.
I found the following discussion that was posted 4 years ago: 502 Gateway Errors under High Load (nginx/php-fpm)
Where someone had a similar issue as mine, but unfortunately I believe that the configurations he received were customized for his own server specs and I can't use the same configuration on my server. Anyway I would like to present the problem I have by myself and not to just tell you to go to the link I sent and read someone else's problem.
So to my own story - I have a big social media page where I post links to my website articles, which means that I have lots of traffic spikes during the day each time I share something. Recently I noticed that the site is too slow and sometimes not loading at all and unfortunately I am not very familiar in solving issues like this and I don't have a system administrator who manages my dedicated server to contact with since I rent it from OVH which offers unmanaged servers in low cost. The server has pretty good specs and this issue happens even when there are 100 active users on site. I can also see some errors in my server logs.
Server specs are the following:
AMD Opteron(tm) Processor 4334, AMD Opteron(tm) Processor 4334 (6 core(s))
SoftRaid 3x160GB SSD
32GB RAM
1Gbps connection
CentOS x64 Linux release 7.2.1511 (Core)
Plesk v12.5.30
The errors I was talking about:
proxy_error_log
2016/10/02 09:49:36 [error] 6931#0: *469804 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416176.6522459983825683593750 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416176.6522459983825683593750"
2016/10/02 09:49:36 [error] 6931#0: *469806 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416176.8384990692138671875000 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416176.8384990692138671875000"
2016/10/02 09:49:38 [error] 6931#0: *469826 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 73.77.251.156, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
2016/10/02 09:49:38 [error] 6931#0: *469830 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 217.123.129.73, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
2016/10/02 09:49:39 [error] 6931#0: *469840 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416179.1317949295043945312500 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416179.1317949295043945312500"
2016/10/02 09:49:39 [error] 6931#0: *469842 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2605:6001:f08a:3400:88d6:8b94:4499:8e36, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
2016/10/02 09:49:39 [error] 6931#0: *469845 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 162.158.75.61, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
2016/10/02 09:49:39 [error] 6931#0: *469847 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416179.6054229736328125000000 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416179.6054229736328125000000"
2016/10/02 09:49:39 [error] 6931#0: *469849 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416179.6478641033172607421875 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416179.6478641033172607421875"
2016/10/02 09:49:39 [error] 6931#0: *469851 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2601:81:4203:1bce:5809:b94c:4616:4730, server: ###.com, request: "POST /wp-admin/admin-ajax.php HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/###/"
2016/10/02 09:49:40 [error] 6931#0: *469853 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2602:306:8b97:11a0:6843:ad77:251e:864a, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
I have tons of these ^
I will now attach some of my configuration files as the guy in the other thread I linked to did, so you will have some sort of idea on what's going on my server.
php-fpm.conf
include=/etc/php-fpm.d/*.conf
[global]
pid = /run/php-fpm/php-fpm.pid
error_log = /var/log/php-fpm/error.log
daemonize = no
/etc/php-fpm.d/www.conf
[www]
listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 250
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 35
pm.max_requests = 500
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
/etc/php-fpm.d/###.com.conf
[###.com]
prefix = /var/www/vhosts/system/$pool
user = ###
group = psacln
listen = php-fpm.sock
listen.owner = root
listen.group = psaserv
listen.mode = 0660
chdir = /
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1
catch_workers_output = yes
php_value[max_input_time] = 60
php_value[max_execution_time] = 60
php_value[memory_limit] = 128M
php_value[open_basedir] = none
sysctl.conf
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.eth0.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.eth0.accept_ra = 0
net.core.somaxconn = 4096
net.ipv4.tcp_fin_timeout = 20
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_syncookies = 1
/etc/nginx/nginx.conf
worker_processes 1;
include /etc/nginx/modules.conf.d/*.conf;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server_tokens off;
include /etc/nginx/conf.d/*.conf;
}
# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;
/etc/security/limits.conf has no configurations, only comments inside.
These are the results for the following commands:
ulimit -n
1024
ulimit -Sn
1024
ulimit -Hn
4096
cat /proc/sys/fs/file-max
3266168
free -m
total used free shared buff/cache available
Mem: 32089 1284 3784 1718 27020 28936
Swap: 1532 1 1531
About fastcgi_params - I have no idea where to find this one on Plesk. I could only find a file with variables that I don't know their values.
Like these lines for example (that's how the whole file look like):
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
I am sorry if there's something missing, I really tried to make it detailed as possible and it's also not easy to find where the configuration files are located with Plesk. I had to do some research for each file I attached above... (That's one of the reasons I don't like Plesk to be honest, but that's what I have atm)
If there are any more configuration files you need me to send, please let me know and I will attach it in the comments. Please also let me know where I can find them (considering that I'm using Plesk v12.5).
It's really important for me to configure the server properly for my needs and for my specs and get rid of the errors, so please help me. :)
Thank you!
Try to increase your php-fpm children number, for example like this:
pm.max_children = 30
pm.start_servers = 10
pm.min_spare_servers = 3
pm.max_spare_servers = 15
then sudden spikes of traffic won't generate the error
make sure you have increased php-fpm backlogs variable:
listen.backlog = 100000
also increase the number of net.core.somaxconn=2000000 (kernel parameters at runtime).
like this :
sysctl net.core.somaxconn=200000
sysctl -p
I appear to be having an issue with my website when I browse around (just clicking links here and there), and my system would return a random 502 Bad Gateway error. I can hit the refresh button and it would appear to work fine.
Error Message:
2012/08/16 11:17:54 [error] 26777#0: *1049 recv() failed
(104: Connection reset by peer) while reading response header from upstream,
client: 66.162.194.10, server: SITE,
request: "GET /wp-admin/admin-ajax.php?action=dashboard-widgets&widget=dashboard_secondary HTTP/1.1",
upstream: "fastcgi://unix:/tmp/php.socket:", host: "SITE", referrer: "SITE/wp-admin/index.php"
2012/08/16 11:17:54 [error] 26777#0: *1049 connect() failed
(111: Connection refused) while connecting to upstream,
client: 66.162.194.10, server: SITE,
request: "GET /wp-admin/admin-ajax.php?action=dashboard-widgets&widget=dashboard_secondary HTTP/1.1",
upstream: "http://127.0.0.1:9000/wp-admin/admin-ajax.php?action=dashboard-widgets&widget=dashboard_secondary",
host: "SITE", referrer: "http://SITE/wp-admin/index.php"
/etc/nginx/nginx.conf:
user www-data;
worker_processes 8;