The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Turn display_errors off?

Discussion in 'General Discussion' started by Joriz, Jan 7, 2007.

  1. Joriz

    Joriz Active Member

    Joined:
    Aug 11, 2004
    Messages:
    32
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    the Netherlands
    cPanel Access Level:
    DataCenter Provider
    I want to put display_errors off in PHP so visitors dont see errors on a website made by customers in their website.
    I think this is a lot safer then showing all those errors on screen to a visitor.

    But when I turned it off I found out that customers cant view the errors there self in the cPanel Error Log.

    I use PHP 5.20 with phpsuexec

    Normally the error part in the php.ini is configured like this:

    Code:
    ; Examples:
    ;
    ;   - Show all errors, except for notices
    ;
    ;error_reporting = E_ALL & ~E_NOTICE
    ;
    ;   - Show only errors
    ;
    ;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
    ;
    ;   - Show all errors except for notices
    ;
    error_reporting  =  E_ALL & ~E_NOTICE
    
    ; Print out errors (as a part of the output).  For production web sites,
    ; you're strongly encouraged to turn this feature off, and use error logging
    ; instead (see below).  Keeping display_errors enabled on a production web site
    ; may reveal security information to end users, such as file paths on your Web
    ; server, your database schema or other information.
    display_errors = On
    
    ; Even when display_errors is on, errors that occur during PHP's startup
    ; sequence are not displayed.  It's strongly recommended to keep
    ; display_startup_errors off, except for when debugging.
    display_startup_errors = Off
    
    ; Log errors into a log file (server-specific log, stderr, or error_log (below))
    ; As stated above, you're strongly advised to use error logging in place of
    ; error displaying on production web sites.
    log_errors = On                  ;
    
    ; Set maximum length of log_errors. In error_log information about the source is
    ; added. The default is 1024 and 0 allows to not apply any maximum length at all.
    log_errors = On                  ;
    
    ; Do not log repeated messages. Repeated errors must occur in same file on same
    ; line until ignore_repeated_source is set true.
    ignore_repeated_errors = Off
    
    ; Ignore source of message when ignoring repeated messages. When this setting
    ; is On you will not log errors with repeated messages from different files or
    ; sourcelines.
    ignore_repeated_source = Off
    
    ...
    
    ; Store the last error/warning message in $php_errormsg (boolean).
    track_errors = Off
    So my question is if there is any way to show the php errors in the Cpanel Error log and not in the browser when someone visits a website with bad coded PHP?
     
  2. mctDarren

    mctDarren Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    664
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    New Jersey
    cPanel Access Level:
    Root Administrator
    In the snippet of your ini file I don't see where you declare the error log file name - you should have something like this:
    Code:
    error_log = error_log
    
    Which will log errors to a log file called "error_log" in the user's directory where the error takes place. Not sure, but I think the error log in cPanel supplies Apache errors, not php logic or code-based errors.
     
  3. Joriz

    Joriz Active Member

    Joined:
    Aug 11, 2004
    Messages:
    32
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    the Netherlands
    cPanel Access Level:
    DataCenter Provider
    I know the server stores the php logs somewhere. But i want to make it possible that costumers can view the php errors who show up in their website can be found in Cpanel so I can disable display errors.
     
  4. mctDarren

    mctDarren Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    664
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    New Jersey
    cPanel Access Level:
    Root Administrator
    Yes, when you add the line I supplied above in your php.ini, it creates a log in the user's directory called "error_log", which they can then review.
     
  5. Joriz

    Joriz Active Member

    Joined:
    Aug 11, 2004
    Messages:
    32
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    the Netherlands
    cPanel Access Level:
    DataCenter Provider
    I'm looking for a nicer solution for customers so that they don’t need to open files.
    Maybe I should request it as feature to make it able for customers to view PHP errors in the error log in cPanel.
     
  6. mctDarren

    mctDarren Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    664
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    New Jersey
    cPanel Access Level:
    Root Administrator
    I see what you mean - you want them to be able to log in to cPanel and see the errors there. It will still have to log it somewhere. IMO, if the user isn't saavy enough to download and read an error log they probably shouldn't be writing PHP scripts in the first place. ;)
     
Loading...

Share This Page