简体   繁体   中英

How can I make PHP display the error instead of giving me 500 Internal Server Error NGINX + PHP7

So, I have 500 error on a page and I want more information why I do have error (because the page works fine in local but not on my server)

I try the following solution preconised in This topic but it doesn't help. I restarted nginx everytime and no changes.

Here is the folder on my server (VPS, no cPanel):

文件夹

here is my actual state of php.ini:

http://pastebin.fr/75379

Any clue?

What you placed at the top of your PHP.INI file is what you would use in an actual.php file to turn on error reporting / show errors on a per file bases. You do not add that to your PHP.INI file.

Example of use in a.php file:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');

If you search your PHP.INI file you will find error_reporting = E_ALL , and display_errors = On are set.

Notice the definitions in the PHP.INI file:

; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; For production environments, we recommend logging errors rather than
; sending them to STDOUT.
; Possible Values:
;   Off = Do not display any errors
;   stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
;   On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = On

You should not display errors in a production environment. You don't want to reveal any extra information to any potential hackers. Also these errors will mean nothing to your users. You should just show a generic error page and log all your errors for your review.

In a development environment I would have them all on and display_startup_errors = On .

I see log_errors = On so you should be getting your error messages logged to: /var/log/nginx/default-error.log . I suggest looking there to find your issue after you fix your PHP.INI file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM