PHP Error Logs in cPanel

Save

Because cPanel offers no dedicated PHP error logs, you will have to manually search the provided logs with all error information to locate an errors caused by PHP scripts on your website. This process may require some time, especially if your logs are long. You may be able to speed up the process by searching for the specific name of the script file using your browser's search function.

cPanel Logs

  • The hosting control panel software cPanel offers tools for you to follow errors that may occur on your website. When you log in to cPanel, the "Error Log" icon appears in the "Logs" section. You will then be able to select a domain or subdomain and view applicable error logs. cPanel groups together HTML errors such as the "404" error that occurs when someone tries to access a page or file on your site, along with scripts like PHP or CGI. The errors include a time stamp, the IP address of the visitor and a brief description of the error such as "File does not exist."

Considerations

  • Your cPanel's error logs open in a small frame in your browser by default when you are accessing them from the control panel. However, you may find it easier to evaluate them by copying the logs into a text editor. This approach also allows you to use the search and highlight feature of your text program to highlight search instances. Alternatively, you can access cPanel error logs with file transfer protocol, or FTP, clients, by looking in the following directory: "/usr/local/apache/logs/error_log".

Warning

  • cPanel only provides the last 300 error messages, in reverse order, when you are logged in through your browser. Thus, you should check the logs as soon as possible to locate errors you wish to remedy. Otherwise, your error may be flushed from the list until it occurs again.

Error Log Script

  • If your website is hosted on a Linux server, you can create your own PHP script to save error logs to your account. Create a blank file in your text editor and save it as "php-errors.log" and upload it to your account in an error folder if preferred. Open your .htaccess file in the root of your website and add the following code to the end of the file:

    Start - Log PHP Errors

    php_flag display_startup_errors off
    php_flag display_errors off
    php_flag html_errors off
    php_flag log_errors on
    php_value error_log /home/path/logs/php-errors.log

    End

    Change the path from "error_log /home/path/logs/php-errors.log" to the absolute path of your newly created error log file. Errors will save to this file and you can access it via the cPanel file manager or FTP client.

Related Searches

References

Promoted By Zergnet

Comments

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!