Apache2 internal server error not being logged - php

I'm doing some web development with the Laravel framework, and I have my jQuery set up so that it sends a request on click of a button to a PHP file, which then returns the result back to my jQuery.
However, every time I click this button I get an Internal Server Error. This is not the problem; rather the error is that my Apache error log does not make any mention of this 500 Internal Server Error. In fact, it doesn't really log anything except for [notice] caught SIGTERM, shutting down and [notice] Apache/2.2.22 (Debian) PHP/5.4.4-14+deb7u12 configured -- resuming normal operations. All that being said, my access.log shows the Internal Server Error happening:
"POST /testing/public/apps/devicecheckout-checkoutdevices HTTP/1.1" 500 833 "http://xxx.xxx.xxx.xxx/testing/public/apps/devicecheckout-checkoutdevices" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
In my php.ini file, I have error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT and log_errors = On.
How can I solve this problem?

Your script causes the apache process with PHP module to crash, as such it does not attempt to write anything to the logs and the parent process is the one logging all it knows: its child process caught SIGTERM.
I solved it by putting die("here") to different places to pinpoint where the crash happens, going deeper into code and all used libraries and frameworks. Then use your jugement to figure out what to do.
One thing I noticed that causes this a lot, is to print_r() a complex object with circular references.

Related

Why POST request can be changed to GET on the way from NGINX to PHP

I have next very strange situation:
POST request to the server.
In nginx logs I see something like that: IP-ADDRESS - ce5c8fb7-0a40-4c4e-9b8e-779cae54d4ad-1522849217932 [11/Jun/2018:11:37:38 +0000] "POST /unsubscribe HTTP/1.1" 400 69 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36"
So, nginx is seeing that request like POST
But if I do echo $_SERVER['REQUEST_METHOD'], I will have "GET" as output.
This happens only for one endpoint "/unsubscribe". For all other endpoints POST request works fine.
There no rules in configs related to "unsubscribe" word.
I did try a lot of variants, tests, turn off cache where is possible. But still same behavior. Probably someone has idea what would be good to try in that situation or someone had same problems before?
P.S.
On there server I have Ubuntu + Nginix + PHP 7.0. Not sure, but probably it can be related to PHP version somehow, because some time ago we upgraded from 5.6 to 7.0

Opencart Internal Server Error

I have a problem with opencarted payment modules. I use version 3.0.0.0 and all modules are working fine except the ones that are in payment section. I get an Internal Server Error which at logs says:
GET /admin/index.php?route=extension/extension/payment&user_token=LpWyMlFDTymqDs4I6Q1iUwUV6sI3VCet HTTP/1.0 http://eshop.capsport.gr/admin/index.php?route=marketplace/extension&user_token=LpWyMlFDTymqDs4I6Q1iUwUV6sI3VCet Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36 303 Apache access
2017-07-12 10:27:38 Warning 94.70.255.140 mod_fcgid: stderr: PHP Fatal error: Can't use method return value in write context in /var/www/vhosts/paokbcstore.gr/eshop.capsport.gr/admin/controller/extension/payment/pp_express.php on line 1282, referer: http://eshop.capsport.gr/admin/index.php?route=marketplace/extension&user_token=LpWyMlFDTymqDs4I6Q1iUwUV6sI3VCet Apache error
2017-07-12 10:28:34 Warning RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
Any possible solutions?
I am using openCart v. 3.0.1.0
and Plesk for web hosting
I was having a similar 500 internal server error when I proccessing the checkout step 6.
My mistake was that, I was imported from an old version of openCart the data of the old Database to the new one.. But, in this senario the new version of openCart has some new table's columns as a saw carefully (such as inside table oc_order: tracking, payment_custom_field and so on). So, I have created these colums again, and now the step 6 from the checkout finally works again..
Iniside Plesk there is a choice saying: error-logs (or you can find it something like: log file, logs files e.t.c.). Inside this file I saw the mistake that says:
"mod_fcgid: stderr: PHP Fatal error: Uncaught exception 'Exception' with message 'Error: Unknown column 'tracking' in 'field list'" that's how I found the issue to my problem..
there are lots of things you could try though:
You could try some of the above...maybe could help you:
clear all caches
disable all extensions and inable them one by one, in order to see which one of them causes the problem..
download the same openCart version that you are using, and upload the checkout core files again.. maybe some of those files broke you code..(although this problem coming from extensions - modules)
check PHP version. Some users in openCart forum said that the problem solved by using the version of PHP 7.
see pp_express what are the needs of this payment proccess (link to github that my help you or maybe ask there: https://github.com/opencart/opencart/blob/master/upload/catalog/controller/extension/payment/pp_express.php)

500 Internal Server Error using SilverStripe

I have a problem with my SilverStripe site after a server upgrade to PHP 5.6. My web host upgraded the server from PHP 5.3 to PHP 5.6 and now a 500 server error occurs on every page.
The message from SilverStripe is:
Sorry, there was a problem with handling your request.
In the server error log files there are no error entries.
In the server access log you can see the 500 error:
ERROR:
[09/Mar/2016:11:12:07 +0100] "GET /Security/login?BackURL=%2Fadmin HTTP/1.1" 500 11398 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36"
Next entry in file is OK:
[09/Mar/2016:11:12:08 +0100] "GET /themes/ustheme/css/us.style.css HTTP/1.1" 304 0 "http://www.example.com/Security/login?BackURL=%2Fadmin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36"
How do I debug and fix this problem?
When switching PHP-version, your cache needs to be flushed. Switch your site to dev-mode to flush without having to logon. Or just delete your cache-directory (or create a root-directory named silverstripe-cache.)
First try to flush the site cache as suggested by Simon Erkelens.
Sometimes flushing the cache will not work. This may be because the SilverStripe version cannot handle the PHP version.
If our site is on a server with cPanel some web hosts allow us to select the PHP version through cPanel. This feature is not on every server with cPanel but hopefully this becomes more common.
Select PHP version may be found in the cPanel software panel:
On the PHP selector screen there is a PHP version select box allowing us to select a PHP version. To change PHP version select an option from the PHP version select box and press the Set as current button. Flush the site cache to see if the site now works.
I recommend using the newest version of PHP that will work with the SilverStripe site so that it is as secure and stable as possible.
run below command to get rid off from internal server error
/dev/build
if your site is
http://silverdemo.com
then run command like below
http://silverdemo.com/dev/build
it will rebuild the database and models

Sever responding with a 500 error and error code 204 off and on, while development server works perfectly

I have searched and searched to find an answer to this strange issue on Google App Engine (PHP). My application generates the error below, but only say once out of 5 or 6 calls. There is absolutely no error on the development server. I have disabled APC caching and have tried things like changing version numbers.
The error shows on the log as follows:
2014-05-14 11:53:30.270 /mapi/index.php?action=login&params%5Blogin%5D=kumar76&params%5Bpassword%5D=kumar123&_=Submit 500 121ms 0kb Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/537.75.14 module=default version=1-0-test
24.55.15.118 - - [14/May/2014:09:53:30 -0700] "GET /mapi/index.php?action=login&params%5Blogin%5D=kumar76&params%5Bpassword%5D=kumar123&_=Submit HTTP/1.1" 500 0 - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/537.75.14" "simplycrowmapi.appspot.com" ms=121 cpu_ms=0 exit_code=204 app_engine_release=1.9.4 instance=00c61b117c1279e8c136be007edf2c17b5bfd1
W 2014-05-14 11:53:30.270
A problem was encountered with the process that handled this request, causing it to exit.
This is likely to cause a new process to be used for the next request to your application.
(Error code 204)
my php.ini:
google_app_engine.enable_functions = "php_sapi_name, gc_enabled, phpinfo"
allow_url_include = "1"
upload_max_filesize = 8M
apc.cache_by_default = "0"
apc.enabled = "0"
I also got this error using CodeIgniter v2.1 and v3 on app engine and got this error as well.
It happens when using $autoload['libraries'] = array('database');
Then after a few random page refreshes this error pops up.
After changing the following in database.php:
'pconnect' => TRUE,
into
'pconnect' => FALSE,
This errors is gone in my application.
Now both version 2.1 and 3 are working for me.
Maybe there is a similar setting in the framework or code you're using.
I had the exact same problem, also resolved by using non-persistent connections. According to App Engine's Cloud SQL documentation https://developers.google.com/appengine/docs/php/cloud-sql/#PHP_Managing_connections it can only serve 12 concurrent connections, which is probably less than the number of front-end PHP processes.
For PDO, that's
PDO::ATTR_PERSISTENT => false

How do you detect what page caused the Internal Server Error?

So, in my .htaccess file I have this ErrorDocument lines:
ErrorDocument 500 http://www.example.com/500
Since my server runs multiple websites from the same core files, I just want to redirect all internal server errors to the same processing page. However, my problem is that it doesn't send any information about the page that cause the error, it redirects the page. I tried changing it to ErrorDocument 500 index.php?500 but that just causes a second internal server error when trying to locate the file. Any ideas on how I can successfully redirect it to my custom 500 error page and still acquire information about the page that caused the error in the first place?
In your ErrorDocument statement, you're giving a URL to a remote page. As a result, Apache sends the user a Location header, and the user goes off on their merry way.
Instead, change the URL to an absolute path to a local script that will handle the error:
ErrorDocument 500 /500.php
The script should be launched with a set of environment variables starting with REDIRECT_ that should contain the various paths and query strings involved in the error.
There is no way to both send the user elsewhere and also capture the information within ErrorDocument itself. On the other hand, your script can capture the information and then redirect the user, if you still want to handle it that way for some reason.
You could always look in the referrer field of the http request to determine on which URL the caller was before
Check your webserver's access log. There you will be able to see which request that is causing the 500 response code.
In Apache (using the default log format), a successful request (200 OK) could look like this:
127.0.0.1 - - [19/Jul/2010:18:25:54 +0200] "GET / HTTP/1.1" 200 663 "-" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8pre) Gecko/20100718 Ubuntu/10.04 (lucid) Namoroka/3.6.8pre"
A request that results in a 500 could look like this:
127.0.0.1 - - [19/Jul/2010:18:24:37 +0200] "GET / HTTP/1.1" 500 631 "-" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8pre) Gecko/20100718 Ubuntu/10.04 (lucid) Namoroka/3.6.8pre"
The response code is in the sixth column.
You can also check your PHP error log, which will contain all PHP errors assuming you've enabled error logging (you should).
Your apache server logs every Error occurs(Though it is configurable). You can able to open and manage this file using FileStream in your PHP website. See http://httpd.apache.org/docs/2.2/logs.html to see more about Apache log file. You can get a tutorial on .htaccess from http://www.freewebmasterhelp.com/tutorials/htaccess/.
To make your own processing, make a PHP file like error.php which will process your errors. You can redirect it using .htaccess file. After that if you want to go to a page you can do that by using header() method.

Categories