PHP Guardian: keep PHP-FPM answering and stop 502 errors early

PHP Guardian checks every PHP-FPM version and pool on every server about once a minute, restarts one that stops answering, limits restarts so a broken config is reported, and flags pools at their worker limit. Plus: block PHP in uploads folders.

14 Nov 2026 3 min read 42 views
PHP Guardian: keep PHP-FPM answering and stop 502 errors early
Share

A PHP-FPM pool that stops answering does not announce itself. nginx keeps running, the server looks healthy, and visitors get 502 Bad Gateway until someone notices and restarts the service. On a server with several PHP versions and one pool per account, there are many places for this to happen. PHP Guardian watches them for you, restarts what has stopped, and tells you when a pool is simply too small for its traffic.

What it watches

About once a minute, the panel worker checks every PHP-FPM version on the panel server and on every online node. For each version it asks two questions:

  1. Is the phpX.Y-fpm service running?
  2. Does each of its pools, one per account and version, accept a connection on its socket?

The second question matters. A service can report itself as active while one pool no longer accepts connections, and only the sites on that pool fail.

Automatic restart, with limits

When a version is down, or one of its pools does not answer, PHP Guardian restarts that version and notifies the administrators through the panel's alert channels. It tells you whether the restart worked.

Restarting forever is not a fix, so restarts are limited per server and per version: three an hour by default, adjustable from 1 to 20. If a configuration keeps failing, you get a report instead of a restart loop. A few cases are deliberately left alone:

  • A PHP version you switched off, with its service disabled or masked, is not restarted.
  • A version that is starting or reloading is not counted as down.
  • A check started from the page and the worker's own check do not run at the same time, so each restart is counted once.

If you prefer to act yourself, turn off Restart automatically. PHP Guardian then only notifies you.

Pools at their worker limit

Not every 502 or slow page comes from a crashed pool. Often the pool is working but every worker is busy, because pm.max_children is set too low for the traffic. PHP Guardian reports pools that reached pm.max_children in the last hour, at most once every six hours per pool. The message says that all workers of the pool were busy, so visitors waited or got errors, and suggests raising pm.max_children in the PHP-FPM app if the server has memory for it.

This report can be switched off with Report pools at their worker limit if you already track it elsewhere.

What you see on the page

  • Each server, its PHP versions and their pools.
  • A manual restart button per version.
  • A history of what happened: restarts, failures and pools at their limit.

The checks only read. The only change PHP Guardian ever makes is restarting PHP-FPM. It is for administrators only.

Related hardening: block PHP in uploads folders

Keeping PHP running is half the job. The other half is making sure PHP only runs where it should. Many website takeovers end the same way: a PHP file is dropped into a writable folder such as wp-content/uploads and then requested through the browser. Refusing to run PHP in that folder stops that step without touching the site's own scripts.

Since panel version 1.4.28, every PHP website has Block PHP in folders on its Advanced tab. You add folders inside the document root, and PHP files there are refused with 403 instead of being run. The panel suggests common candidates such as wp-content/uploads, uploads, images, media, storage, cache, tmp and files. How it is applied depends on the web server:

  • nginx: one snippet per site, read before the site's own PHP location. It is tested with nginx -t, and if the test fails the previous snippet is restored and nothing changes.
  • Apache and OpenLiteSpeed: a marked block in each folder's .htaccess, written as the site owner. A folder that does not exist yet is created, so later uploads are covered too.

Folder names are validated: no .., no absolute paths, up to 30 folders per site. Use it only for folders that hold uploads or cache, never for folders with the site's own scripts. If you also use Site Doctor, its WordPress check warns when wp-content/uploads still allows PHP and points you to this setting.

How to get it

PHP Guardian is in the Vinza Store and needs VinzaPanel 1.4.30 or later, with the panel worker (vinza-worker) running, since the worker runs the checks. Install it from Vinza Store, review the three settings, and make sure your alert channels under Settings are configured so restart notices reach you. For the folder protection, open any PHP website, go to Advanced and choose Block PHP in folders.