Why can't I see what the Error is. On youtube, when they forgot to put in a ; an error along with which file and which line on that file was displayed. When I get an error, I just get:
Server Error
500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.
How do I get it to show what the error is?
I think that is a server error, and not a php error, but in your php.ini file towards the bottom and not in the examples, there are error reporting options. Be sure you change them back to no, after the error is corrected, this is a security measure to keep your code private.
As far as a 500 error, check your apache logs.
Related
I'm on a server with apache2.4, php7.2, mysql (on linuxmint)..
I enabled the proxy_fcgi module and php-fpm to enable the http2 protocol.
Everything is working fine, but I am kind of bugged by the fact that now, php parsing errors are just outputted on the apache error log (of the virtual host).
For example if I omit a semicolon at the end of a line with a define() function somewhere in the php file before a new define().., I get that error in the log:
[proxy_fcgi:error] [pid 16261:tid 140594642073344] [client 127.0.0.1:36542] AH01071: Got error 'PHP message: PHP Parse error: syntax error, unexpected 'define' (T_STRING) in /var/vhosts/localhost/index.php on line 12\n'.
Which is fine, but in the browser I get no error at all, I just have a 500 Internal server status blank page.
Before setting up the proxy I used to get the php parsing errors displayed in the browser, which is much easier to debug, it's annoying to keep the error log open to check whatever small parsing error I might have.
Please don't try to get me to install an IDE editor, or use "php -l filename.php". I simply want the errors back in the browser output.
I have all the settings properly defined in all php.ini files, display_errors On, error_reporting E_ALL. It's all working fine since it's outputted to the error log :)
What I'd like to know is how to setup fpm/fcgi to stop outputting a 500 error page in the browser and actually re-forward the php errors straight in the browser as a 200 page, how it was before installing this proxy..
In the specific example, I would like to have "PHP Parse error: syntax error, unexpected 'define' (T_STRING) in /var/vhosts/localhost/index.php on line 12\n'" on the browser output again :)
Having the same problem while installing the latest Prestashop on my server. So as #Agnes Tom has recommended, I changed the define.inc.php file and this is the error it´s showing up:
Warning: session_start(): open(/var/php_sessions/sess_b3c24487f16e9dcc7ebe9b0897bee69f, O_RDWR) failed: No such file or directory (2)
in /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/install/classes/session.php on line 47 Notice: Use of undefined constant _NEW_COOKIE_KEY_ - assumed '_NEW_COOKIE_KEY_'
in /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/classes/Cookie.php on line 79 Fatal error: Uncaught exception 'Defuse\Crypto\Exception\BadFormatException' with message 'Encoding::hexToBin() input is not a hex string.'
in /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/vendor/defuse/php-encryption/src/Encoding.php:65 Stack trace:
#0 /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/vendor/defuse/php-encryption/src/Encoding.php(164): Defuse\Crypto\Encoding::hexToBin('_NEW_COOKIE_KEY...')
#1 /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/vendor/defuse/php-encryption/src/Key.php(38): Defuse\Crypto\Encoding::loadBytesFromChecksummedAsciiSafeString('\xDE\xF0\x00\x00', '_NEW_COOKIE_KEY...')
#2 /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/classes/PhpEncryptionEngine.php(112): Defuse\Crypto\Key::loadFromAsciiSafeString('_NEW_COOKIE_KEY...')
#3 /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/classes/PhpEncryptionEngine.php(46): PhpEncryptionEngineCore::loadFromAsciiSafeString('_NEW_COOKIE_KEY...')
#4 /hermes/bosnaweb14a/b1 in /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/vendor/defuse/php-encryption/src/Encoding.php on line 65
Warning: Unknown: open(/var/php_sessions/sess_b3c24487f16e9dcc7ebe9b0897bee69f, O_RDWR) failed: No such file or directory (2) in Unknown on line 0
Warning: Unknown: Failed to write session data (files).
Please verify that the current setting of session.save_path is correct (/var/php_sessions) in Unknown on line 0
Might anyone helping me to know how to solve this error??
Thank you for your time
It's throwing an error saying it can't find or write to '/var/php_sessions/'
Do you have full access to the server?
If so, check if that folder exists and if the user or web server has permission to write to it, or change in php.ini
session.save_path = "/var/php_sessions"
To something like :
session.save_path = "/home/user/sessions"
Again, must be an existing folder with read/write permissions for the user or web server (this depends if you run the web server as own user or as account user).
If it's a shared envoirement, you better contact you hosting provider. Some allow you to have a php.ini in your hosting root and you could use it to change the session.save_path, others ignore it.
How to recognize the Error 500
First, we need to go over the different ways you might see this error message on your computer. There are different forms of this message because each host/server is allowed to customize the way it’s displayed. Here are some common ways you might see this error.
“500 Internal Server Error”
“HTTP 500 – Internal Server Error”
“Internal Server Error”
“HTTP 500 Internal Error”
“500 Error”
“HTTP Error 500″
Most times you will see this message accompanied by various forms of this classic ambiguous line
“The server encountered an unexpected condition that prevented it from fulfilling the request by the client”
It’s important to note that this error can be shown on any browser and any operating system (sorry, but switching to the new Mac Pro will not solve this problem) Here is a screenshot of one of the ways this error might be displayed on your browser.
Internal error server
What is the 500 Error?
Put simply, the 500 error is the Web servers way of saying “Something went wrong but I can’t tell you what, sorry.” This is what we call a “server-side” error. That means that there is something wrong with the server who is hosting the website. It is an extremely general error usually caused by configuration issues with the websites programming, PHP or system permissions.
How Can I Troubleshoot?
Don’t fret; although this error message is absurdly vague, you still have ways to find more information. Web servers are almost always configured to hide specific error messages. If your PrestaShop store is suffering from this debilitating error, you can turn on PrestaShop’s Error Reporting from FTP or your hosting’s CPanel to get more details.
There are two ways to turn on Error Reporting in PrestaShop depending on what version you have.
For PrestaShop v1.4 through v1.5.2
Open config/config.inc.php
On or around line 29 you will find this line
#ini_set('display_errors', 'off');
Change that line to read
#ini_set('display_errors', 'on');
For PrestaShop v1.5.3+
Open config/defines.inc.php
On or around line 28 you will find this line
define('_PS_MODE_DEV_', false);
Change that line to read
define('_PS_MODE_DEV_', true);
Once you enable error reporting through your FTP or CPanel, you can navigate back to your PrestaShop’s front or back office and reproduce the error or issue you are having. For example, if you are not able to access your website because of the 500 error, you will need to turn on error reporting and refresh the page(s) that had the error. There will be additional information that you can use to investigate the problem.
Investigating the Error
Once you have the additional information, there are some standard ways to further investigate the error. First, let’s go over some the most common ways this problem is caused. Once we find the cause of this error, it is much easier to solve.
Permissions: Many times you will find that the permission setting on one of your folders is set incorrectly. It could be a simple fix as switching a file/folder permission from 777 to 755 or vice versa. In most cases permission sets of 777 are extremely unsafe and can allow even an amateur hacker to access your files and put malicious code in it. Make sure to check with your hosting provider for specific information about permissions set as some servers have different regulations.
Incorrectly configured .htaccess: Oftentimes you will receive an internal server error when the htaccess file is configured incorrectly. For PrestaShop purposes, the main culprits of the htaccess errors are “URL Rewrite” settings or Friendly URL enabling. The htaccess syntax is very strict so even one wrong character or command will cause the server to return an Internal Error 500. Make a backup of your htaccess and regenerate the htaccess file either through the back office or by toggling the Enable Friendly URL option.
Server timeout: Every server has their own timeout setting, which sets the time that any given script can run. If the function or script crosses that limit, you will receive an error 500. The most common scripts in PrestaShop that can take too long to load are CSV Imports, backups, translation loading, import/exports and thumbnail regeneration. Many times the server limit is 30 seconds, which is not long enough to run these scripts. You should contact your hosting provider and inquire about changing the limit, at least temporarily.
Now, if the problem is not solved by investigating these common causes, you should also take a look at the Apache and PHP Error logs. These are provided by your hosting provider but sometimes you will need to contact them directly in order to have access to these log files.
Is there a general explanation for the errors that lead to the phenomenon described in the title? Can I make the program tell me the actual cause of these errors?
Assuming you are using PHP backend, HTTP status 500 would mean internal server error - a bug that caused your PHP script to halt. Usually fatal errors cause this.
When you get a 500 error, click on the request in firebug. It would open up all kinds of request data like Headers, Response, Cache, Params etc. Check the response tab once. That might give you a clue about what's wrong in your PHP code.
An HTTP status code of 500 means the error happened on the server side. Firebug only sees what's happening on the client side - i.e. it tells you that the server returned an error code. It doesn't have access to the errors happening on the server side.
I.e. you need to check the log files of your server to see what caused the error. This is normally a fatal error in your server-side script that caused its execution to stop.
OK The server encountered an internal error or misconfiguration and
was unable to complete your request. Please contact the server
administrator, admin#example.com and inform them of the time the error
occurred, and anything you might have done that may have caused the
error. More information about this error may be available in the
server error log.
I get this message everytime I run the code. I have no idea where the error is.. I checked through the apache error file, and some other error log files..and found nothing about the mistake..how do I trace the errror
I think that is the error that I see:
> [8/27/2012 12:28:57 PM] Error: PHP process 35344 from the "application/x-httpd-php" pool has exited with status 255.
[8/27/2012 12:28:57 PM] Error: Read data error - unable to get read result. Code 109.
[8/27/2012 12:28:57 PM] Error: Request for C:/Program Files (x86)/Zend/Apache2/htdocs/backlinks/cron/links-buy.php: Unable to get the response from PHP process
Thats what I see in the event viewer:
> php-cgi.exe
> 5.3.9.0 4ef33bca ZendOptimizerPlus.dll
> 0.0.549.0 4f00c7dd c0000005 000061a1 8554 01cd8436d2089924 C:\Program Files
> (x86)\Zend\ZendServer\bin\php-cgi.exe C:\Program Files
> (x86)\Zend\ZendServer\lib\optimizerplus\php-5.3.x\ZendOptimizerPlus.dll
> 112872b4-f02a-11e1-aed2-8c89a53c9045
Add die(); in the middle of your code. Try it. If error still occurs your error in first part. Then divide your error part ino two by die(); and so on.
Open your php file. It seems to be the file /Zend/Apache2/htdocs/backlinks/cron/links-buy.php. Determine a location on your file system where to write your PHP error output. E.g. use '/home/myuser/public_html/phpDebugErrorLog.txt'. Replace this path!
Add many statements like this to your PHP file (consider the syntax of PHP). Add different numbers 1, 2, 3, ....., 100 .
error_log('Position 1: ' . chr(13), 3, '/home/myuser/public_html/phpDebugErrorLog.txt');
some PHP code here;
error_log('Position 2: ' . chr(13), 3, '/home/myuser/public_html/phpDebugErrorLog.txt');
some more PHP code;
error_log('Position 3: ' . chr(13), 3, '/home/myuser/public_html/phpDebugErrorLog.txt');
So you determine the position in your PHP file where the error happens which crashes your CGI PHP script. The last line which is shown in your error log file will give you the position in the file which has the bug. Then fix the bug in PHP.
given the following script
<?php
ini_set('display_errors','On');
error_reporting(E_ALL);
thisisanerror
?>
I get the expected
Notice: Use of undefined constant error - assumed 'error' in /htdocs/test.php on line 8
but if I add something to the script
<?php
ini_set('display_errors','On');
error_reporting(E_ALL);
error
function test () {
echo('test');
}
?>
I get
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
Why am I getting a 500 error instead of a normal syntax error in the latter case? Shouldn't display_errors always display the error?
The second code sample is an outright syntax error. This means PHP will not progress to the point of code execution and will die at parse time. Since no code is executed, the effects of the ini_set() call are not seen, so you do not get the PHP textual error indicating the problem.
A parse error is fatal, and the web server is (rightly) set to handle PHP fatal errors with a 500 response code. Since your PHP script did not produce any output the web server will return it's default error document for the 500 condition.
If you want to see the textual message for parse errors in the browser - and one wouldn't normally do this is production, by the way - you will need to turn error reporting on in php.ini or using a .htaccess file.
If forcing php to show error on run time doesn't work for you, you may try other options like setting it in php.ini instead:
error_reporting = E_ALL | E_STRICT
display_errors: On
Good Luck!