PHP-FPM

PHP 7.4 through 8.5 compiled from source with OPcache, Redis, ImagicK, and 30+ extensions. Use centmin.sh Menu 5 (PHP Upgrade / Downgrade) to switch PHP versions with full source recompilation.

Table of Contents
Infographic showing PHP-FPM configuration and optimization in Centmin Mod including pool management, OPcache settings, and PHP version upgrades

Default PHP Versions

132.00stable & 140.00beta01: PHP 7.4.33  |  141.00beta01: PHP 8.3.21

After installation, switch to any supported version (7.0–8.3 on 132.00stable/140.00beta01; 7.0–8.5 on 141.00beta01) via centmin.sh Menu 5.

Latest Upstream: ...  |  ...  |  ...  |  ...  |  ...  |  ...  |  ...

PHP-FPM process manager modes: Centmin Mod defaults to pm = ondemand with pm.max_children = 30 in /usr/local/etc/php-fpm.d/www.conf. Three modes available: ondemand (default, spawns workers on demand up to pm.max_children), dynamic (scales between pm.min_spare_servers and pm.max_children), and static (fixed pm.max_children workers always running). See php.ini Customization for details.

PHP Versions

Centmin Mod compiles PHP from source and supports the following versions (configurable via Menu 5):

PHP Version Status Latest Upstream Notes
PHP 8.5 (141.00beta01 only)Active...Latest development branch
PHP 8.4 (141.00beta01 only)Active...Current stable release
PHP 8.3Active...Default in 141.00beta01
PHP 8.2Security...Security fixes only
PHP 8.1Security...Security fixes only
PHP 8.0EOL...End of life; custom OpenSSL patches for EL9
PHP 7.4EOL...Default in 132.00stable/140.00beta01; custom OpenSSL patches for EL9

EL9/EL10 Compatibility

PHP 7.4 and 8.0 on EL9/EL10 systems require Centmin Mod’s custom OpenSSL 1.1.1w patches for compatibility with the system’s OpenSSL 3.x libraries.

PHP Extensions

Centmin Mod includes the following PECL and built-in extensions:

Caching & Performance

  • Zend OPcache — Bytecode caching (built-in)
  • Redis (phpredis 6.3.0) — Redis client
  • igbinary — Binary serializer for Redis/sessions
  • Memcached — Memcached client extension
  • APCu — User data caching

Image & Media

  • ImagicK (3.8.1) — ImageMagick bindings
  • GD — Image processing with AVIF support (PHP 8.1+)
  • libheif — HEIF/HEIC image format

Database

  • MySQLi — MySQL improved driver
  • PDO MySQL — PDO driver for MySQL/MariaDB
  • MongoDB — MongoDB driver (PHP 8.3+)

Compression & Encoding

  • zstd — Zstandard compression
  • lz4 — Fast lossless compression
  • lzf — LZF compression
  • Brotli — Brotli compression
  • mbstring — Multibyte string handling

Security & Crypto

  • OpenSSL — SSL/TLS support
  • sodium — Modern cryptography
  • mcrypt — Available as addon for PHP 7.2–8.0

Other

  • Swoole — Async I/O and coroutines
  • mailparse — RFC 822 email parsing
  • GeoIP — Geographic IP lookups
  • IMAP — Email access protocol
  • intl — Internationalization

How to Install PHP Extensions in Centmin Mod

Beyond the built-in extensions listed above, you can install PHP extensions in Centmin Mod using several methods: (1) install PECL extensions directly, (2) compile from source using phpize, or (3) rebuild PHP via menu option 5 with PHP_EXTRAOPTS. Some extensions also have dedicated addon scripts (e.g., addons/php72-mcrypt.sh for mcrypt, addons/ioncube.sh for IonCube).

Method 1: PECL Extensions

Install PECL extensions directly, then create a .ini file in /etc/centminmod/php.d/ to load it:

pecl install extension-name
echo "extension=extension-name.so" > /etc/centminmod/php.d/extension-name.ini
service php-fpm restart

Method 2: Compile from Source (phpize)

For extensions not in PECL, compile from source using phpize:

cd /path/to/extension-source
phpize
./configure
make
make install
echo "extension=extension-name.so" > /etc/centminmod/php.d/extension-name.ini
service php-fpm restart

Method 3: PHP Configure Flags (Menu 5 Rebuild)

To add built-in PHP extensions that require compile-time flags, set PHP_EXTRAOPTS in /etc/centminmod/custom_config.inc before running centmin.sh menu option 5 to rebuild PHP:

# Add custom PHP configure flags in /etc/centminmod/custom_config.inc
PHP_EXTRAOPTS='--enable-extension-name'

# Then rebuild PHP via menu option 5
centmin

Verify loaded PHP extensions with:

php -m

Tip

Additional .ini files placed in /etc/centminmod/php.d/ are automatically loaded by PHP-FPM and persist across PHP upgrades.

Example: Install PHP APCu on PHP 8.x

APCu (APC User Cache) provides a shared memory-based user data cache for PHP. Below is a step-by-step example of manually compiling and installing APCu using the phpize method (Method 2 above).

Step 1: Download and Compile APCu

cd /svr-setup
pecl download apcu
tar xzf apcu-*.tgz
cd apcu-*/
phpize
./configure --with-php-config=/usr/local/bin/php-config
make -j$(nproc)
make install

Step 2: Create APCu Configuration File

Create /etc/centminmod/php.d/apcu.ini with the following contents:

extension=apcu.so
apc.enabled=1
apc.shm_size=32M
apc.ttl=7200
apc.enable_cli=0

Step 3: Restart PHP-FPM and Verify

fpmrestart
php --ri apcu

Reinstall After PHP Upgrades

APCu must be reinstalled after each PHP upgrade via centmin.sh menu option 5. The compiled extension is tied to the specific PHP version and will not work after switching PHP versions without recompiling.

For more details, see the forum discussion.

php.ini Customization

PHP configuration files are located at:

  • /usr/local/lib/php.ini — Main php.ini
  • /etc/centminmod/php.d/ — Additional .ini files (scan directory)
  • /usr/local/etc/php-fpm.conf — PHP-FPM main config
  • /usr/local/etc/php-fpm.d/www.conf — Default PHP-FPM pool configuration (main/default pool)
  • /usr/local/nginx/conf/phpfpmd/ — Optional additional PHP-FPM pool configuration files (numbered pools, not enabled by default)

Where Is the PHP-FPM Pool Configuration File?

In Centmin Mod, the default PHP-FPM pool configuration file is at /usr/local/etc/php-fpm.d/www.conf — this is NOT the standard OS path /etc/php-fpm.d/www.conf. All vhosts share a single default [www] pool (listening on port 9000) via the php.conf include. Optional numbered pools (pool2–pool5) are available at /usr/local/nginx/conf/phpfpmd/ but are disabled by default.

PHP-FPM Pool Configuration

By default, all Nginx vhosts share a single PHP-FPM pool — the [www] pool defined in /usr/local/etc/php-fpm.d/www.conf, listening on 127.0.0.1:9000. Each vhost includes /usr/local/nginx/conf/php.conf which routes PHP requests to this shared default pool. Key tuning directives include pm.max_children (maximum worker processes, default 30), the process manager mode (pm = ondemand by default), and pm.min_spare_servers/pm.max_spare_servers for dynamic mode.

  • Default pool config: /usr/local/etc/php-fpm.d/www.conf — shared by all vhosts via php.conf include
  • Optional additional pools: /usr/local/nginx/conf/phpfpmd/ contains template files for numbered pools (phpfpm_pool2.conf on port 9002, phpfpm_pool3.conf on port 9003, etc.) and Unix domain socket variants
  • Enabling additional pools: Uncomment include=/usr/local/nginx/conf/phpfpmd/*.conf in /usr/local/etc/php-fpm.conf, then change the vhost’s include php.conf to include php-pool2.conf (etc.)

To tune the default PHP-FPM pool settings (pm.max_children, pm.start_servers, etc.), edit /usr/local/etc/php-fpm.d/www.conf and restart PHP-FPM with service php-fpm restart.

PHP-FPM Process Manager Modes and pm.max_children

Centmin Mod's default PHP-FPM process manager mode is ondemand (set as pm = ondemand in /usr/local/etc/php-fpm.d/www.conf). Three process manager modes are available — ondemand (default), dynamic, and static. All three modes use the pm.max_children directive to set the maximum number of PHP-FPM worker processes (default: pm.max_children = 30). The key difference is how each mode manages workers relative to pm.max_children:

  • pm = ondemandDefault mode. Spawns workers on demand up to pm.max_children, best for low-memory VPS.
  • pm = dynamic — Scales workers between pm.min_spare_servers and pm.max_children based on demand, general-purpose.
  • pm = static — Fixed pm.max_children workers always running, best for high-traffic dedicated servers.

The pm.max_children setting controls the maximum number of PHP-FPM worker processes. Calculate it as: (Available RAM − RAM for MySQL/Nginx/OS) ÷ average worker memory. Centmin Mod defaults to pm.max_children = 30. See the PHP-FPM Optimization & Tuning section for detailed sizing guidance.

Tip

For persistent PHP configuration changes, use /etc/centminmod/php.d/ scan directory. Files here survive PHP upgrades.

Per Nginx Vhost PHP.ini Settings

By default, all Nginx vhosts share the same PHP-FPM pool and PHP settings. To configure per-site PHP settings (such as different upload_max_filesize or memory_limit values for each domain), you can enable separate PHP-FPM pools and use php_admin_value directives in each pool configuration.

Advanced Configuration

This is an advanced configuration. The default single [www] pool at port 9000 works fine for most setups. Only use separate pools when you need per-site PHP settings that cannot be set via .user.ini files.

Step 1: Enable Additional PHP-FPM Pools

Uncomment the pool include line in /usr/local/etc/php-fpm.conf:

# In /usr/local/etc/php-fpm.conf, uncomment this line:
include=/usr/local/nginx/conf/phpfpmd/*.conf

Step 2: Use a Pre-Existing Pool Configuration

Centmin Mod provides pre-existing pool template configs at /usr/local/nginx/conf/phpfpmd/. For example, phpfpm_pool5.conf listens on port 9005. Add php_admin_value directives to the pool config for per-site PHP settings:

/usr/local/nginx/conf/phpfpmd/phpfpm_pool5.conf
[pool5]
listen = 127.0.0.1:9005
; ... existing pool settings ...

; Per-site PHP settings
php_admin_value[upload_max_filesize] = 50M
php_admin_value[post_max_size] = 55M
php_admin_value[memory_limit] = 256M
php_admin_value[max_execution_time] = 120

Step 3: Create a Custom Nginx Vhost Include

Create a custom Nginx vhost include file phpcustom-yourdomain.conf that references the pool port (e.g., 127.0.0.1:9005 instead of the default 127.0.0.1:9000):

phpcustom-yourdomain.conf
# Custom PHP include pointing to pool5 on port 9005
fastcgi_pass 127.0.0.1:9005;

Then update your Nginx vhost config for that domain to include phpcustom-yourdomain.conf instead of the default php.conf. Restart both PHP-FPM and Nginx:

fpmrestart
ngrestart

For more details, see the forum discussion.

PHP-FPM Security

Centmin Mod applies security hardening to PHP-FPM by default:

  • PHP-FPM runs as the nginx user with limited permissions
  • expose_php = Off to hide PHP version headers
  • disable_functions restricts dangerous functions
  • Separate PHP-FPM pools can isolate users/sites

open_basedir Restrictions

The open_basedir directive restricts which directories PHP scripts can access. It can be set per-vhost in the Nginx configuration:

Nginx vhost config
fastcgi_param PHP_VALUE "open_basedir=/home/nginx/domains/domain.com/:/tmp/";

PHP Upgrade / Downgrade (Menu 5)

Use centmin.sh menu option 5 to upgrade or downgrade PHP on existing Centmin Mod installs. Supported PHP versions: PHP 7.4, 8.0, 8.1, 8.2, 8.3 on 132.00stable/140.00beta01; PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5 on 141.00beta01. This recompiles PHP from source with all extensions.

Terminal — Menu 5 Interactive Session (141.00beta01 — PHP 8.4/8.5 available on this branch only)
-------------------------------------------------------- Centmin Mod Menu 141.00beta01 centminmod.com -------------------------------------------------------- 1). Centmin Install 2). Add Nginx vhost domain 3). NSD setup domain name DNS 4). Nginx Upgrade / Downgrade 5). PHP Upgrade / Downgrade 6). MySQL User Database Management 7). Persistent Config File Management 8). PostgreSQL Server Management 9). Option Being Revised (TBA) 10). Memcached Server Re-install 11). MariaDB MySQL Upgrade & Management 12). Zend OpCache Install/Re-install 13). Install/Reinstall Redis PHP Extension 14). SELinux disable 15). Install/Reinstall ImagicK PHP Extension 16). Change SSHD Port Number 17). Multi-thread compression: zstd,pigz,pbzip2,lbzip2 18). Suhosin PHP Extension install 19). Install FFMPEG and FFMPEG PHP Extension 20). NSD Install/Re-Install 21). Data Transfer 22). Add Wordpress Nginx vhost + Cache Plugin 23). Update Centmin Mod Code Base 24). Exit -------------------------------------------------------- Enter option [ 1 - 24 ] 5 -------------------------------------------------------- ____ _ _ ____ _ _ _ | _ \ | | | || _ \ _ | | | | _ __ __ _ _ __ __ _ __| | ___ | |_) || |_| || |_) |(_) | | | || '_ \ / _` || '__|/ _` | / _` | / _ \ | __/ | _ || __/ _ | |_| || |_) || (_| || | | (_| || (_| || __/ |_| |_| |_||_| (_) \___/ | .__/ \__, ||_| \__,_| \__,_| \___| |_| |___/ PHP Upgrade/Downgrade - Would you like to continue? [y/n] y ---------------------------------------------------------------- Install which version of PHP? (i.e. 7.3.33, 7.4.33, 8.0.30, 8.1.34, 8.2.30, 8.3.30, 8.4.19, 8.5.4, NGDEBUG) PHP 7.x/7.1.x/7.2.x/7.3.x is GA Stable but still may have broken PHP extensions. NGDEBUG is PHP 8.5 dev builds minus incompatible PHP extensions ---------------------------------------------------------------- Current PHP Version: 8.5.3 Latest PHP Version Installable: 8.5.4, 8.4.19, 8.3.30, 8.2.30, 8.1.34, 8.0.30 Enter PHP Version number you want to upgrade/downgrade to: 8.5.4 Do you still want to continue? [y/n] y ---------------------------------------------------------------- existing php.ini will be backed up at /usr/local/lib/php.ini-oldversion_110326-022804 ---------------------------------------------------------------- ----------------------------------------------------------------------------------------- Detected PHP 8.5 branch. You can compile Zend OPcache (Zend Optimizer Plus+) support as an alternative to using APC Cache or Xcache cache. But Zend OPcache only provides PHP opcode cache and DOESN'T do data caching, so if your web apps such as Wordpress, Drupal or vBulletin require data caching to APC or Xcache, it won't work with Zend OPcache. ----------------------------------------------------------------------------------------- Do you want to use Zend OPcache [y/n] ? y

PHP Profile-Guided Optimization (PGO) compiles are supported for PHP 7.4+ with GCC to improve PHP-FPM performance by 5-15%.

PHP-FPM Status Page

The PHP-FPM status page is available at /phpstatus and is restricted by IP whitelist in /usr/local/nginx/conf/phpstatus.conf. By default, only 127.0.0.1 is allowed.

To view from within SSH, use lynx or curl. To view from a browser, add your IP to the phpstatus.conf allow list.

Terminal
# View PHP-FPM status via command line curl -s http://localhost/phpstatus # Full status with per-process details curl -s http://localhost/phpstatus?full

Status Fields Explained

Field Description
active processesNumber of currently active worker processes
idle processesIdle workers waiting for requests
total processesTotal active + idle workers
max active processesHighest concurrent active processes since start
max children reachedTimes the process limit was reached (increase pm.max_children if > 0)
slow requestsRequests exceeding slowlog threshold

Security Backports for EOL PHP Versions

Centmin Mod actively backports CVE security patches to end-of-life PHP versions via inc/php_patch.inc. These patches are applied automatically during PHP (re)installs and upgrades via Menu 5, reducing exposure even on versions that no longer receive upstream security releases.

PHP Version Upstream Status Centmin Mod CVE Backports
PHP 8.0.xEOLThrough 2025 (cve-2025-* series, ghsa-www2-q4fc-65wf)
PHP 7.4.33/34EOLThrough 2025 (cve-2025-* series, cve-2025-14177/78)
PHP 7.3.xEOLThrough 2025 (ghsa-4w77-75f9-2c8w)
PHP 7.2.xEOLThrough 2025 (cve-2024-11236, ghsa-4w77-75f9-2c8w)
PHP 7.1.xEOLThrough 2024 (cve-2024-8927 series)
PHP 7.0.xEOLThrough 2024 (cve-2024-8927 series)
PHP 5.6.xEOLThrough 2024 (cve-2024-8927 series)
PHP 5.5.x, 5.4.xEOLLimited (bug #81719)
PHP 5.3.xEOLphp53.patch
PHP 8.1.x, 8.2.xSecurityStandard upstream security releases (no Centmin Mod backports needed)

Upgrade Recommended

While Centmin Mod backports reduce exposure, EOL PHP versions have no upstream security support. Upgrading to PHP 8.3+ is strongly recommended for production servers.

PHP-FPM Troubleshooting & Error Logs

When PHP-FPM shows errors on your Centmin Mod server, the first step is to check the PHP-FPM error log. The default error log location is /var/log/php-fpm/www-error.log. Check recent errors with:

# Check PHP-FPM error log for recent errors
tail -100 /var/log/php-fpm/www-error.log

# Check PHP-FPM service status
systemctl status php-fpm

# Validate PHP-FPM pool configuration syntax
php-fpm -t

# Restart PHP-FPM after fixing configuration issues
service php-fpm restart

Common PHP-FPM Errors

  • 502 Bad Gateway: PHP-FPM is not running or has crashed. Check /var/log/php-fpm/www-error.log for out-of-memory or segfault errors, then restart with service php-fpm restart.
  • 504 Gateway Timeout: PHP scripts exceeding time limits. Increase max_execution_time in /usr/local/lib/php.ini and request_terminate_timeout in /usr/local/etc/php-fpm.d/www.conf.
  • Connection refused on port 9000: PHP-FPM is stopped or listening on a different port/socket. Verify with ss -tlnp | grep 9000 and restart if needed.
  • Too many children reached: The pm.max_children limit is too low for the load. Increase it in /usr/local/etc/php-fpm.d/www.conf based on available RAM.

Also check the slow request log at /var/log/php-fpm/www-slow.log to identify PHP scripts that take too long. See the PHP-FPM Optimization & Tuning section for slow log setup and pm.max_children sizing guidance.

PHP-FPM Optimization & Tuning

To optimize PHP-FPM worker pool settings for high traffic in Centmin Mod, edit the default pool configuration at /usr/local/etc/php-fpm.d/www.conf. Key settings include pm.max_children, the process manager mode (pm = dynamic, pm = ondemand, or pm = static), slow request logging, and OPcache tuning.

Worker Pool Sizing

The pm.max_children setting in /usr/local/etc/php-fpm.d/www.conf determines the maximum number of PHP-FPM worker processes. Calculate based on available RAM:

# Check average memory per PHP-FPM worker
ps --no-headers -o rss -C php-fpm | awk '{ sum+=$1; count++ } END { print sum/count/1024 " MB avg per worker" }'

# Formula: pm.max_children = (Available RAM - RAM for other services) / Average worker memory
# Example: (4096MB - 1024MB for MySQL/Nginx/OS) / 50MB per worker = ~60
Process Manager Best For Behavior
pm = dynamic General-purpose servers Scales workers between min and max based on demand
pm = ondemand Low-memory VPS Spawns workers only when needed, frees memory during idle
pm = static High-traffic dedicated servers Fixed number of workers always running, no spawn overhead

Centmin Mod default: Centmin Mod sets pm = ondemand in /usr/local/etc/php-fpm.d/www.conf with pm.max_children = 30 to conserve memory on VPS servers. Workers are spawned on demand and freed after pm.process_idle_timeout seconds of inactivity. Adjust pm.max_children based on available RAM. You can switch to pm = dynamic or pm = static for high-traffic workloads.

Slow Request Logging

Enable slow request logging to identify PHP scripts that take too long to execute:

# In /usr/local/etc/php-fpm.d/www.conf
slowlog = /var/log/php-fpm/www-slow.log
request_slowlog_timeout = 5s

Review the slow log to identify which PHP scripts and functions are consuming the most time, then optimize or cache those code paths.

OPcache Tuning

Key OPcache settings in /usr/local/lib/php.ini or /etc/centminmod/php.d/zendopcache.ini:

# Increase if "opcache.max_accelerated_files" full warning appears
opcache.max_accelerated_files = 50000

# Memory for cached scripts (increase for large WordPress sites)
opcache.memory_consumption = 256

# How often to check for file changes (0 = every request, production = 60)
opcache.revalidate_freq = 60

Memory Diagnostics

Use the built-in PHP memory analysis tool:

# Per-process PHP-FPM memory analysis
/usr/local/src/centminmod/tools/php-memory-limit-summary.sh

Performance Tools

Run tools/hptweaks.sh for kernel-level performance tuning:

# Kernel tuning: transparent huge pages, jemalloc allocator
/usr/local/src/centminmod/tools/hptweaks.sh

For more details, see the forum discussion. Also see Troubleshooting — High CPU Load.

Need help?

Join the community forums for PHP-FPM configuration help and optimization tips.