Bobcares

A rapid way to set up PHP FPM error reporting & real-time solutions

by | May 23, 2019

PHP FPM handler can boost the website performance even on high traffic.

Sometimes, websites using PHP FPM show unexpected errors. And, the users may not have a clue on the underlying reason.

Fortunately, PHP fpm error reporting gives real-time details on the causes of the error. But, to make use of this we need to turn on error reporting for the website.

At Bobcares, we often get requests to fix PHP FPM errors as part of our Server Management Services.

Today, we’ll see how our Support Engineers set up PHP FPM error reporting and fix the related errors.

Importance of PHP FPM error reporting

PHP FPM error logging provides a simple but efficient solution for logging all errors into a log file. Also, the information they contain will give exact details of errors and the amount of time spent on tracking the root causes of errors.

For instance,

The entries in the PHP FPM error logs look like.

[22-Mar-2019 16:52:18] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 9 idle, and 89 total children

Luckily, it is very easy to troubleshoot after analyzing the PHP-FPM error log and our Support Engineers found that this error occurs due to the values of pm.min/max_spare_servers and pm.start_servers. Then we increased these two values in /etc/php-fpm.d/www.conf.

Similarly, another example of entries in the PHP FPM error logs.

[25-Apr-2019 16:28:20] WARNING: [pool www] server reached max_children setting (80), consider raising it

From the error log, we could identify that this error happens when pm.max_children setting reached its threshold value and our Support Engineers increased this value of pm.max_children in the PHP-FPM configuration file.

However, only a proper configuration of PHP FPM error reporting will provide useful entries to help fix the root cause of errors.

 

How we set up PHP FPM error reporting.

Now, let’s see how our Support Engineers set up PHP FPM error logging on servers.

To configure error logging for PHP-FPM,

1. Firstly, we need to configure log file names and location.

By default, we’re using www.conf pool config file or find php-fpm.conf or www.conf depending on what version of PHP-FPM you have installed. Here, we took /etc/php/7.0/fpm/pool.d/www.conf as an example.

2. So, we edit /etc/php/7.0/fpm/pool.d/www.conf file and uncomment “catch_workers_output=yes"

3. At last, we restart  php-fpm service.

 

How we nailed the errors related to PHP FPM error reporting

From our experience in managing server, we’ve seen that many customers had issues related to  PHP FPM error logging. Let’s take a look at the top problems and how we fix them.

 

Improper configuration settings

Recently, one of our customers had an issue PHP FPM error logging. He couldn’t find anything in the error log after enabled FPM error reporting.

Then, our Support Engineers found that he set up PHP-FPM error log in the wrong configuration file.

Therefore, we found the exact file location by using the following command.

ps aux | grep fpm

root 1508 0.0 1.5 367260 31380 ? Ss Nov05 0:11 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf)
www-data 10231 0.0 2.7 453420 55540 ? S 15:10 0:03 php-fpm: pool www
www-data 13266 0.0 2.4 449892 50900 ? S 22:13 0:00 php-fpm: pool www
www-data 13572 0.0 1.8 372468 37740 ? S 23:14 0:00 php-fpm: pool www
user+ 13721 0.0 0.0 14512 980 pts/0 R+ 23:30 0:00 grep --color=auto fpm

 

Next, we edited /etc/php/7.0/fpm/php-fpm.conf and properly configured it.

That fixed the problem.

 

Incorrect permission/missing log file

Sometimes, PHP FPM error logging may not work as we expect even if we set up the right configuration. This can happen due to missing log files or lack of write permissions for a webserver on the log file.

For example, if the permission of error log fpm-php.www.log is incorrect, the error logging will not work properly. The same thing happens in the case of missing log files.

When a customer reported problems with error logging we executed the following command to verify the files. But, files were missing as per the logs below.

ls /usr/local/etc/php-fpm.d/fpm.log
ls: cannot access '/usr/local/etc/php-fpm.d/fpm.log': No such file or directory
ls: cannot access '/usr/local/etc/php-fpm.d': No such file or directory

 

Then our Support Engineers created the directory and log file fpm.log. And, then set up the right ownership.

This is how we fixed the error.

 

[Having trouble while setting up PHP FPM error reporting? We’ll fix it for you.]

 

Conclusion

In short, PHP FPM error logging provides a simple but efficient solution for logging all errors into a log file. Today, we saw how our Support Engineers set up PHP FPM error reporting and solved related issues.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.