PHP Guardian & PHP Folder Blocking
PHP Guardian & PHP Folder Blocking
This page covers two PHP safety tools:
- PHP Guardian, a Store app that keeps PHP-FPM answering on every server and restarts it before visitors keep getting 502 errors.
- Block PHP in folders, a built-in website setting that refuses to run PHP in upload and cache folders.
PHP Guardian
Requirements
- Panel 1.4.30 or later, with the panel worker (
vinza-worker) running: it runs the checks. - Free app, available on every plan. Administrators only.
What it does
- About once a minute it checks every PHP-FPM version on the panel server and on every online node: whether the
phpX.Y-fpmservice is running, and whether each pool (one per account and version) accepts a connection on its socket. - A version that is down, or one whose pool does not answer, is restarted and the administrators are notified through the panel's alert channels.
- Restarts are limited per server and version (3 an hour by default), so a broken configuration is reported instead of restarted forever.
- Pools that hit
pm.max_childrenin the last hour are reported (at most once every six hours per pool), with the advice to raise it if the server has memory for it. - A version you switched off yourself (disabled or masked service) is left alone, and one that is starting or reloading is not counted as down.
The checks only read. The only change PHP Guardian ever makes is restarting PHP-FPM.
Open it
Install PHP Guardian from the Vinza Store, then open Management → PHP Guardian (/apps/php-guardian/). The page lists each server with its PHP versions and their pools, and their state: Answering, Not answering, Down (automatic restart is off), Down, restart limit reached or switched off.
- Check now runs a check immediately instead of waiting for the worker.
- Restart next to a version restarts it by hand. Requests in progress on it are cut off.
- What happened is the history: restarted automatically, restarted by hand, restart failed, pool at its worker limit. Clear empties it.
Settings
| Setting | Effect |
|---|---|
| Restart automatically | On: a down version is restarted. Off: it is only reported |
| At most … restarts per hour per version | 1 to 20 (default 3). When the limit is reached, the version is reported and left alone until the hour passes |
| Report pools at their worker limit | Alert when every worker of a pool was busy, so visitors waited or got errors |
Click Save after changing them.
When a pool keeps hitting its worker limit
Raise pm.max_children for that PHP version in the PHP-FPM app (see PHP-FPM Configuration), but only if the server has memory for more workers. Otherwise look for slow scripts in the site's error log; Site Doctor shows the recent errors.
Troubleshooting
- Not checked yet: the worker has not run yet. Click Check now, and make sure
vinza-workeris running (see Service Recovery). - Down, restart limit reached: the configuration is probably broken. Check the PHP-FPM configuration and its log before restarting by hand.
- Could not check this server: the panel could not reach that node's agent.
Block PHP in folders
Most website takeovers end with a PHP file dropped into a writable folder such as wp-content/uploads and then opened in a browser. Refusing to run PHP there stops that step without touching the site's own scripts. This is built into the panel from version 1.4.28; no app is needed.
Set it up
- Open Websites, click the website and go to its Advanced tab.
- In the PHP section, click Block PHP in folders.
- Type a folder inside the document root, for example
wp-content/uploads, and click Add. Suggestions are shown under the field:wp-content/uploads,uploads,images,media,storage,cache,tmp,files. - Click Save. PHP files in those folders and below are now refused with HTTP 403.
The card appears only for PHP websites and for users who can manage the site. Up to 30 folders per site are allowed; paths with .. or absolute paths are refused.
Never add a folder that holds the site's own scripts (for example wp-admin or your application's code): those pages would stop working.
How it works per web server
| Web server | What the panel writes |
|---|---|
| Nginx | One snippet, /etc/nginx/vinza-site/<domain>/vinza-php-deny.conf, read before the site's PHP location. It is tested with nginx -t; if the test fails, nothing is changed and the previous snippet is kept |
| Apache2 / OpenLiteSpeed | A marked block in each folder's .htaccess, written as the site owner. Your other .htaccess lines are kept. A folder that does not exist yet is created, so later uploads are covered too |
Removing a folder from the list removes its rules again. Changes are recorded in the audit log.