502 gateway errors with nginx php-fpm and wordpress site - php

i have problems with one of 2 websites running on a centos server through NGINX + PHP-FPM.
For one of the websites running WordPress WooCommerce and a couple of plugins it feels like randomly getting 502 timeouts.
Especially on accessing category/archive or single product pages.
CPU and memory load is ok, also no errors or warnings here
What i can see from the logs is the following
/var/log/php-fpm/error.log
[27-Nov-2017 11:58:16] NOTICE: finished trace of 719
[27-Nov-2017 11:58:36] WARNING: [pool www] child 703, script '/srv/www/domain.com/public_htm/index.php' (request: "GET /index.php") executing too slow (15.478662 sec$
[27-Nov-2017 11:58:36] NOTICE: child 703 stopped for tracing
[27-Nov-2017 11:58:36] NOTICE: about to trace 703
[27-Nov-2017 11:58:36] NOTICE: finished trace of 703
/var/log/nginx/domain-error.log
[error] 30981#0: *18683 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 162.158.89.37, server: www.kixl.de, request: "GET /sneaker/asics HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001",
thats pretty much it. Sometimes pages are reachable again, otherwise i have to restart php-fpm.
I would really like to find out the real reason behind these timeouts but donĀ“t know where to look.
I already tried changing debug levels for NGINX and PHP-FPM to debug and more without getting more details what exactly causing the trouble.
I depend on the plugins and theme activated for this wordpress install so deactivating or using default theme is no option here.
Maybe someone can tell me how to find out what File, Plugin or maybe some database query causing PHP-FPM to hang, leading in the web server to timeout.

Related

Internal server error 500 crashes server laravel

Every time there is 500 error server cpu gets 100% and crashes needs to restart every time
PHP Version 7.4
Laravel Version 8.83
Ubuntu Ngnix
I found this in php7.4-fpm.log error logs
[13-Sep-2022 08:13:16] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
[13-Sep-2022 08:19:05] NOTICE: Terminating ...
[13-Sep-2022 08:19:05] NOTICE: exiting, bye-bye!
error.log
2022/09/13 10:52:53 [error] 889#889: *3130 upstream timed out (110: Connection timed out) while reading response header from upstream
2022/09/13 11:09:41 [crit] 889#889: *148 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while SSL handshaking
Does anyone know about this?
Your PHP-FPM config is set to the default 5 children (simultaneously executing PHP requests) and that limit is (on occasion it appears) being exceeded and hence the 500 error. Have a read of this article if you want background knowledge on the PHP-FPM max_children setting.
There is also a handy online calculator for calculating a more appropriate max_children value for your server configuration.
Once you have calculated a new (higher) value for the setting, you'll need to update your PHP-FPM configuration and reset the PHP-FPM service on your server for the change to take effect.

PHP Internal Server error on Nginx replacewildcardsinredirecturl()

I was installing a script that require ionCube loaders on a Ubuntu 16.04 with PHP5.6 and Nginx. ionCube Loaders appear to be working according to phpinfo page.
http://tutt2.com/phpinfo.php
Although majority of pages are working, I'm getting a 500 Internal Server Error on page which is supposed to redirect to a third party page. This is the page that is giving the error.
http://tutt2.com/base.php?c=7&key=c98f46504d315fb435212cc15093d045&test=true
As you can see it's not redirecting. And this is what I see on NGINX error log.
2017/08/26 04:45:26 [error] 16801#16801: *767 FastCGI sent in stderr: "PHP Fatal error: Call to undefined function replacewildcardsinredirecturl() in /home/tutt2/public_html/basecode.php on line 0" while reading response header from upstream, client: 113.59.210.222, server: tutt2.com, request: "GET /base.php?c=7&key=c98f46504d315fb435212cc15093d045&test=true HTTP/1.1", upstream: "fastcgi://unix:/var/php-nginx/15023718282643.sock/socket:", host: "tutt2.com", referrer: "http://tutt2.com/direct-and-landing-campaign.php?id=7"
I'm not sure what replacewildcardsinredirecturl() is. I've looked in basecode.php but it doesn't help since it's encrypted. Hope someone can point me to right direction.
Thanks in advance.

505 Error Heroku Deploying Personal Website

I'm trying to host my personal website on heroku. My website only has html, css, and javascript files, and I read that heroku only deploys apps written in ruby, node, scala, php, etc. So, I followed this tutorial (http://www.lemiffe.com/how-to-deploy-a-static-page-to-heroku-the-easy-way/) and changed my index.html file to home.html and included an index.php file that has the following code: <?php include_once("home.html"); ?>.
I've successfully pushed it to heroku, but when I open the heroku url of my app, it gives me a 505 error.
Below is my heroku log:
2015-11-14T02:42:05.497208+00:00 heroku[api]: Deploy 63ae6bd by email#gmail.com
2015-11-14T02:42:05.497305+00:00 heroku[api]: Release v4 created by email#gmail.com
2015-11-14T02:42:05.651545+00:00 heroku[slug-compiler]: Slug compilation started
2015-11-14T02:42:05.651555+00:00 heroku[slug-compiler]: Slug compilation finished
2015-11-14T02:42:05.820048+00:00 heroku[web.1]: State changed from up to starting
2015-11-14T02:42:08.998026+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-11-14T02:42:09.746422+00:00 heroku[web.1]: Starting process with command `vendor/bin/heroku-php-apache2`
2015-11-14T02:42:09.909064+00:00 app[web.1]: Going down, terminating child processes...
2015-11-14T02:42:10.844965+00:00 heroku[web.1]: Process exited with status 0
2015-11-14T02:42:12.439647+00:00 app[web.1]: Starting php-fpm...
2015-11-14T02:42:12.243079+00:00 app[web.1]: Optimizing defaults for 1X dyno...
2015-11-14T02:42:12.435588+00:00 app[web.1]: 4 processes at 128MB memory limit.
2015-11-14T02:42:14.442033+00:00 app[web.1]: Starting httpd...
2015-11-14T02:42:14.672772+00:00 heroku[web.1]: State changed from starting to up
2015-11-14T02:44:38.663711+00:00 heroku[router]: at=info method=GET path="/" host=mywebsite.herokuapp.com request_id=45aae2bd-a6f8-4023-86cf-6aedd5d23882 fwd="138.110.234.184" dyno=web.1 connect=12ms service=2ms status=500 bytes=224
2015-11-14T02:44:38.663113+00:00 app[web.1]: [14-Nov-2015 02:44:38 UTC] PHP Parse error: syntax error, unexpected '?' in /app/index.php on line 1
2015-11-14T02:44:38.663580+00:00 app[web.1]: 10.146.233.83 - - [14/Nov/2015:02:44:38 +0000] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36
You said 505 error (505 is really quite an exotic error!) but it is actually just a 500 error according to the log you pasted. 500 is the typical server side error, in this case:
PHP Parse error: syntax error, unexpected '?' in /app/index.php on line 1
I'd bet your php file has a space in it or something that isn't quite right. Make sure it looks like what you pasted as instructed here: https://stackoverflow.com/a/17531897/237091
Well , whenever your Web-page's contain HTML, CSS and JavaScript , so follow just 2 steps :
1) Make one file give name as index.html (keep evreything in it) ex:script,stylesheet & body.
2) Now, change these file, copy and paste these same file but change domain to index.php
Then deploy on a Heroku.
Hence this method will help you to deploy your Web-Pages

Yosemite Nginx PHP crashes on curl_exec

I have OSX 10.10 Yosemite with Nginx and PHP installed using Homebrew. I am trying some stuff with Symfony, but I have discovered that when I run my scripts, as soon as they reach the method call curl_exec, all execution is aborted and the server throws a 502 Bad Gateway error.
I created a separate script outside the Symfony scope and ran it with the PHP version I installed via Homebrew, and it worked perfectly fine. It is my assumption that there is an issue with PHP-FPM, however, as opposed to most other posts on StackOverflow, it's not like all PHP scripts are crashing, or that the curl extension isn't installed. Because all PHP scripts work, and curl method calls work, except for curl_exec.
Also, when the curl_exec function is called via Nginx, this is the line that is added to the error log:
2015/06/02 23:01:43 [error] 13355#0: *10 upstream prematurely closed
connection while reading response header from upstream, client:
127.0.0.1, server: mysubdomain.localhost, request: "GET /app_dev.php/users/create?XDEBUG_SESSION_START=19867 HTTP/1.1",
upstream: "fastcgi://127.0.0.1:9000", host: "mysubdomain.localhost:8080"
EDIT: As per nifr's request, here's what appears in my PHP error log:
[04-Jun-2015 09:25:58 America/Los_Angeles] PHP Warning: PHP Startup:
mcrypt: Unable to initialize module Module compiled with build
ID=API20131226,NTS PHP compiled with build ID=API20131226,NTS,debug
These options need to match in Unknown on line 0 [04-Jun-2015
09:26:03 America/Los_Angeles] PHP Warning: PHP Startup: mcrypt:
Unable to initialize module Module compiled with build
ID=API20131226,NTS PHP compiled with build ID=API20131226,NTS,debug
These options need to match in Unknown on line 0
However, this appears regardless of whether I use curl or not. It appears even when I so much as do a echo 'Hello World';, so I'm pretty sure this has nothing to do with curl_exec.
EDIT 2: I found another person who seems to have the same issue: php-fpm crashed when curl or file_get_contents request a https url
However, it is even more severe for them, because on my side, file_get_contents does not cause any crashes.
EDIT 3: nginx log:
[21-Oct-2015 11:39:39] WARNING: [pool www] child 73043 exited on
signal 11 (SIGSEGV) after 201.232240 seconds from start [21-Oct-2015
11:39:39] NOTICE: [pool www] child 73216 started

Suddenly error with wordpress only with nginx (Uncaught SyntaxError: Unexpected end of input)

I've installed Wordpress on my VPS and is run smoothly with apache2. But recently , I recognized that it consume too much RAM (~600MB for 7-8 session) so I decided to change to Nginx. After changing for few days, it's working fine, without any problem but suddenly yesterday, the Admin Page layout was destroyed. I looked into the console log and found out this problem: Uncaught SyntaxError: Unexpected end of input, the file was wp-admin/load-scripts.php.
You can access to the file directory as
http://vietnammechkey.com/wp-admin/load-scripts.php?c=0&load%5B%5D=jquery-core,jquery-migrate,utils,json2&ver=3.8.2
The file will be longer if I use Apache2 and it will be sorter if I use nginx
Note: The Wordpress working perfectly on Apache2.
This is a fairly old question, and I guess by now you must have figured it out by yourself. I just came across the same issue. In my case, it was caused by bad permissions. Excerpt from my /var/log/nginx/error.log:
2015/03/13 16:07:18 [crit] 21806#0: *276 open()
"/var/lib/nginx/fastcgi/2/03/0000000032" failed (13: Permission denied)
while reading upstream, client: 81.253.76.64, server: yoga-maragata.fr, request:
"GET /wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=4107-20150118 HTTP/1.1",
upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.yoga-maragata.fr",
referrer: "http://www.yoga-maragata.fr/wp-admin/post.php?post=7&action=edit"
It was obviously a permission issue, and as it happens, I had just changed the nginx user setting in /etc/nginx/nginx.conf. Reverting to www-data solved the issue.

Categories