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.
Nature of Drupal 7 "website encountered an unexpected error" ?
The common causes of this error includes:
- PHP version conflict.
- Syntax error in the configuration file.
How to fix Drupal 7 "website encountered an unexpected error" ?
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:
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:
- We can adjust the PHP setting easily from cPanel using the following steps:
- First, log in to the hosting cPanel.
- And locate the MultiPHP Manager tool in the Software section of the cPanel.
- After that, click the checkbox for the domain(s) that we wish to adjust.
- Now from the drop-down menu labeled PHP version, select the PHP version that best suits the site code.
- Finally, click the blue Apply button to save the change.
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:
[Trying to fix any Drupal error? We can help you. ]