PHP error log is empty - how to prevent this

Post Reply
User avatar
Team Member
Posts: 129
Joined: Mon Jul 19, 2021 1:41 am
Has thanked: 14 times
Been thanked: 3 times

There have been instances where PHP scripts have forced error_reporting(0) to turn off PHP error logging.
If you want to prevent this and ensure PHP error logging is always turned on, we can follow the tutorial for PHP-FPM pool.d conf files - viewtopic.php?f=18&t=54 - and do the following.

First, check what PHP version you are running on the domain.

In your SSH run:

Code: Select all

sudo /usr/local/vesta/bin/v-get-php-version-of-domain
The output will be, for example:

Code: Select all

Now we know the location of our PHP-FPM pool.d conf, it's: /etc/php/8.0/fpm/pool.d/

Let's edit your PHP-FPM pool.d conf:

Code: Select all

sudo mcedit /etc/php/8.0/fpm/pool.d/
Find the last line that begins with php_admin_flag
After that line, add:

Code: Select all

php_admin_value[error_reporting] = E_ALL
Press F2 on your keyboard and confirm saving.

Press ESC twice on your keyboard to exit the editor.

In the end, restart your PHP-FPM by running:

Code: Select all

sudo systemctl restart php8.0-fpm
(NOTE: it may be some other PHP version, depending on what PHP version your domain is using)

Post Reply