Hostwinds Tutorials
Search results for:
Table of Contents
Tags: cPanel
This guide will explain how to create a PHP error log file in cPanel for your primary domain name. This will require you to add and edit files in the file manager, including the .htaccess to follow along in this guide. If you have trouble diagnosing errors on your site, this guide can help provide some more information by enabling error logs.
Step 1: Navigate to the File Manager in your cPanel
Step 2: Select the public_html folder and the folder for your domain.
Step 3: By default, the .htaccess file is hidden. Click on Settings on the upper right side of the page to view the settings.
Step 4: Click on the Save button.
Step 5. Back in your file manager, right-click your .htaccess file, and select edit.
Step 6. Copy and paste the following code in your .htaccess file and click on Save Changes:
php_flag display_errors off
php_flag log_errors On
php_value error_log /home/Username/public_html/phperror.log
You will need to change the Username above to your cPanel username
This will put the error log in the file named phperror.log in your public_html folder or create this if the file does not exist. You can customize the location of the file or the file name by editing the file path.
Step 6b: Locate your cPanel/FTP username in your cPanel homepage in the upper right corner of your cPanel homepage
You can add an error log for each domain by creating a separate .htaccess file in the domain's document root. You can combine these by keeping the file path as shown above for the phperror.log file the same.
Step 1. Create a new PHP file named errortest.php in your public_html folder and add this code to produce an error:
\<!?PHP
function fun1()
{
ech "SHOW ME THE ERROR";
}
fun2();
echo "Fatal Error !!";
?>
This will produce an error due to the incorrect spelling of echo and using it instead.
Step 2. Access the file using your favorite browser. For example, go to the file from your domain, ex. domain.com/errortest.php
This will cause an error to be logged in your ~/public_html/errortest.php file, and nothing will show up on this page.
Option 1. Right-click the phperror.log and select view
Your phperror.log should look like this when it has been created.
Option 2. You can also view the phperror.log file by going to 'domain.com/phperror.log' (replace 'domain.com' with your actual domain)
Written by Hostwinds Team / September 20, 2018