Share this:

Technorati ReddIt Favorites

Getting PHP errors from server

The most important step in debugging problems with the website (WordPess powered or any other) is to be able to get errors logged on the server side. This is not always as straightforward process as you might think and there are different approaches to have and find error logs.

Any web software, and this include WordPress and plugins for it will work as you expect it in most cases. But, no matter how good the code for plugins is, it can happen that some server setups can break it. Also, other plugins can cause problems. Best way to determine the problem is to get server side errors. Most servers are by default set to log all errors into the file, and to hide them from the user. With shared hosting, you usually can’t control this, and if the errors are not logged, you must consult your hosting company support to enable error logging. If you have own server (VPS or dedicated) you have full access, and you should be able to disable or enable error logs when you need them. I can’t get into details on this, it depends on the server. Error logs can be PHP specific, or they can contain all sorts of errors merged into same files.

Most used control panels for servers are cPanel and Plesk, and here is the information how to get logs from these two. They allow you to see all errors compiled in one place. But, PHP can be set to save error logs in folders where the errors have occurred, so you will need to go through website folders to find these files. They are usually named error_log.

Plesk

Plesk

Plesk

Plesk is great control panel that works with Linux and Windows servers. To get error logs in Plesk, open Websites and Domains tab (this can differ, depending on Plesk version and edition), and usually hidden are advanced operations. When you open them, you will see Logs as on the image on the right.

When you open Logs, you will get list of websites. For each website you have separate set of logs. Select website you want and you will get a long (usually) list of log files. Find file named error_log and that is the latest one. Old error log files are usually archived.

And, you can set Plesk to send you archived error logs to your email each day or each week.

cPanel

cPanel

cPanel

cPanel is most popular control panel for Linux hosted websites. To get the error logs, you need to open Advanced Statistics panel. There you should have Error Log button. Once you click on it, you will get error logs for all websites you have installed, or each individual error log (depends on the server configuration). If there is not Error Log button, or if there are no error logs, it’s most likely that error logging is disabled on your server.

WordPress error logging

If this doesn’t help, and you didn’t found error logs, you can set up WordPress to save errors into file. To do this, you need to modify the wp-config.php file.

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
define('WP_DEBUG_LOG', true);

First line will activate error reporting for all types of errors including strict and deprecated errors. Second define will activate displaying errors on the screen. Last line will activate logging errors into the file. This file will be debug.txt in your wp-content folder, so make sure that that folder is writable for WordPress. This way, you will get errors in the file that is easy to find.

Leave a Reply

Follow us on Twitter

Date Archives

Social Networks

Google Plus Profile Subscribe to RSS feed LinkedIn Profile Follow me on Pinterest Watch our Youtube Videos Find us on Flickr

Feedburner Feedburner updates

Sign up to receive news from this website to your email.

Recent Blog Posts

Dev4Press on YouTube

Share This

Technorati ReddIt Favorites