πŸ“„
Webhosting

Setting up and configuring PHP-FPM for your website

πŸ“… 10 November 2026 ✏️ 10 November 2026 ⏱ 5 min leestijd

PHP-FPM ensures faster and more stable websites. Learn how to configure it, understand the key parameters, and solve common problems.

PHP-FPM (FastCGI Process Manager) is how your server processes PHP requests. Properly configured, it ensures faster load times and fewer error messages during busy periods. In this article, you’ll learn what PHP-FPM does, which settings really make a difference, and how to resolve common problems such as 502 errors or slow responses.

What is PHP-FPM and why use it

PHP-FPM is a process that executes PHP code separately from your web server (such as Nginx or LiteSpeed). Instead of starting a new PHP process for every visitor, FPM keeps a pool of ‘worker processes’ ready to handle requests directly. This saves startup time and gives you control over how much memory and how many processes PHP is allowed to use.

The alternative, mod_php, runs PHP as part of Apache itself. This works, but is less flexible and often slower with many simultaneous visitors. Virtually all modern hosting environments, including webhosting with LiteSpeed, therefore use PHP-FPM or a similar variant (LSAPI) under the hood.

Key PHP-FPM settings explained

The PHP-FPM configuration is usually located in a pool file, for example /etc/php/8.x/fpm/pool.d/www.conf. These settings determine the behavior:

  • pm: the process management type. Usually dynamic (processes scale up and down) or ondemand (processes only start on request, useful with low traffic).
  • pm.max_children: the maximum number of simultaneous PHP processes. Set too low, this causes waiting times or 502 errors during busy periods; too high can exhaust your server’s memory.
  • pm.start_servers: the number of processes ready immediately at startup.
  • pm.min_spare_servers and pm.max_spare_servers: the margin of idle processes FPM maintains to absorb peaks.
  • pm.max_requests: after how many requests a worker restarts. This prevents memory leaks caused by sloppy code.
  • request_terminate_timeout: after how many seconds a stuck PHP script is terminated.
πŸ’‘ Tip: calculate pm.max_children based on the available memory divided by the average memory usage per PHP process (visible via your monitoring or with ps aux), not by copying a fixed number from the internet.

Configuring PHP-FPM: step-by-step plan

Here’s how to safely adjust the settings on a Linux server:

1

Open the pool configuration file

Go to the folder for your PHP version, for example /etc/php/8.2/fpm/pool.d/www.conf, and open the file with a text editor such as nano or vim.

2

Adjust pm and the child processes

Set pm = dynamic and fill in realistic values for max_children, start_servers, min_spare_servers, and max_spare_servers based on your server resources.

3

Set timeouts and max_requests

Set pm.max_requests to a value between 500 and 1000 and request_terminate_timeout a few seconds above your expected script duration.

4

Test the configuration

Check the syntax with php-fpm -t before restarting, so you don’t cause downtime due to a typo.

5

Restart the PHP-FPM service

Restart the service with, for example, systemctl restart php8.2-fpm and check the status with systemctl status php8.2-fpm.

If you use Plesk, you can also adjust many of these settings per domain via the interface, without having to dive into configuration files yourself. This is more convenient if you manage multiple websites.

Solving common problems

Most PHP-FPM problems fall into a few categories:

  • 502 Bad Gateway during busy periods: this often indicates pm.max_children is set too low, causing the web server to run out of free workers. Increase the number of processes or check whether your server has enough memory.
  • Website responds slowly under low load: check whether pm.start_servers and min_spare_servers are not set too low, causing new processes to constantly need to start up.
  • Memory usage keeps increasing: lower pm.max_requests so workers restart more often, reducing the chance of memory leaks.
  • Scripts get stuck or time out: check request_terminate_timeout and look in the PHP-FPM slowlog (slowlog and request_slowlog_timeout in the pool file) to see which scripts run too long.

If in doubt, always check the error logs of PHP-FPM and your web server first. They usually show exactly which limit was hit.

Frequently asked questions

Is PHP-FPM always better than mod_php?

For most modern websites, yes, because it is more flexible and efficient with server resources, especially with multiple websites on one server.

Which PHP version should I use?

Always choose an actively supported PHP version that is compatible with your CMS or framework. Older versions no longer receive security updates.

Can I adjust PHP-FPM settings on shared hosting?

This depends on your package and control panel. In Plesk, you can often manage a number of FPM-related settings yourself per domain.

What happens if max_children is set too high?

Then your server may allow too many processes simultaneously, which can exhaust available memory and slow down the entire server instead of just that one website.

Conclusion

Properly configuring PHP-FPM is about balance: enough processes for busy periods, but not so many that your server runs short on memory. Start with realistic values based on your server resources, always test the configuration before restarting, and keep an eye on logs if problems arise. If you get stuck, our support is happy to help.

View webhosting β†’

Was dit artikel nuttig?