Drupal users often encounter the "The website encountered an unexpected error. Please try again later" message either after updating the core or while enabling modules.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to resolve related Drupal errors.
The common causes of this error includes:
To begin, we must enable error reporting as it will help us to gather more ideas on the error.
Do the following.
1. Check for errors behind the scenes
We can monitor the errors being generated by our site by running the following command on the server:
$ tail -f /var/log/apache2/error.log
2. Change settings in your dev site
We can see all errors by adding a few lines to our local testing site’s settings.php:
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
In addition, we can navigate to Administration and take Configuration, then go to Development and go to logging and errors. In that section, we can select "All messages" (This sets $conf['error_level'] = 2;).
3. Switch on strict PHP error reporting
We can go to the development site’s php.ini file, in the php folder, and switch all error reporting on.
To do this, we have to access the php.ini file and set error_reporting to E_ALL.
Warning: as the PHP documentation states, this setting is only for development sites, not for production sites.
4. Changing the PHP version of the site
In most cases, this error could be related to differences with the PHP version of the site.
So we can try changing the PHP version of the site to the latest one.
Steps to change PHP version from Cpanel:
5. Restore the configuration file
At times the changes we make in the configuration file can trigger this error.
If any changes were made to the settings.php file, we can try reverting it and see if it fixes the issue. We may also try restoring this file from the backup.
6. Try running an updatedb
We could also try running the database update. This will run any pending database updates:
drush updb
This article covers method to resolve Drupal 7 "website encountered an unexpected error" ?
To find out what the real problem is,