0

I am facing a The website encountered an unexpected error. error while setting up the site.

Most of the documentation I found online suggest to enable logging in the setting.php file.

I added this line in site/default/settings.php.

$config['system.logging']['error_level'] = 'verbose';

I added the following code.

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

I added the following lines to the same settings.php file, at the bottom.

if (file_exists(__DIR__ . '/settings.local.php')) {
  include __DIR__ . '/settings.local.php';
}

I copied the sites/example.sites.php file to sites/default/ and renamed it settings.local.php, as suggested on https://catwolf.org/qs?id=180d30e9-9dcb-4e96-b030-7df34c77f5ab&x=x and https://www.drupal.org/forum/support/post-installation/2018-07-18/enable-drupal-8-backend-errorlogdebugging-mode.

I restarted Apache and reloaded the site, but I see the same error shows again without any log.

I am migrating a Drupal 7.84 site from CentOS 6.10 to CentOS 7.9. The httpd passes from version 2.2.15 to version 2.4.6; it also has PHP 7.03 and MariaDB 10.3.

Did I miss anything, or do I have to do anything else to enable the logging?

4
  • If you added those settings just below <?php, make sure that they are not overwritten later in the file. Also, example.sites.php is not a template for settings.local.php. BTW - What is your version of Drupal? In 7 the setting name was different. May 3 at 9:14
  • My drupal version is 7.84. I don't know where I have to add this line. Once I resolve this I will remove those lines as it is the production server. I am in the migration process. I am migrating the drupal 7.84 site from centos 6.10 to centos 7.9. Httpd version also changes from 2.2.15 to 2.4.6. Php v7.03 and mariadb v10.3. I hope this info may help May 3 at 9:21
  • If you are temporarily adding lines to a file to try to change things, always add them to the bottom of the file first. This will ensure that the lines override any logic in the file because they will be the last to be executed. May 3 at 11:17
  • Added as you said @patrick but no luck. shows asusual same error May 3 at 12:27

2 Answers 2

1

Here's the official manual for Drupal 7: https://www.drupal.org/docs/7/creating-custom-modules/show-all-errors-while-developing

At the end of your sites/default/settings.php, add the following lines:

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
$conf['error_level'] = 2;

Please pay extra attention to the last line, as it is specific to D7. Your code was for D8/D9.

Of course those changes can be also made to settings.local.php, but I would try to do it after making sure that $conf['error_level'] = 2; works at all at the end of settings.php.

1
  • Thanks for your suggestion @grzegorz. I tried to add it at the end of the setting.php file but no luck. Do you know why it didn't execute? May 3 at 12:24
1

Please try the following:

  • in the webroot, rename .htaccess to .htaccess.old -- Apache 2.4 has changed syntax in some directives that may be causing the error before PHP is even reached. Also check apache log files ( usually /var/log/httpd/error.log, see your VirtualHost for other paths )
  • check your PHP file logs, since some errors never make it to the screen even with all the above listed directives -- on CentOS these are normally under /var/log/php*

One of the above should have a log entry on what went wrong.

2
  • Thanks for you suggestion @nick i checked all the logs you mentioned For apache log, [core:notice] [pid 22268] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0 [Tue May 03 07:22:21.732165 2022] [suexec:notice] [pid 22268] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)........ For php log fpm is running, pid 1497 NOTICE: ready to handle connections NOTICE: systemd monitor interval set to 10000ms NOTICE: Terminating NOTICE: exiting, bye-bye!......... I disabled the firewall and SELinux but shows the same error May 3 at 12:31
  • I renamed the .htaccess file as you mentioned and reloaded the apache and site but same error appears May 3 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.