Hero Image

Install PHP-FPM on Debian 12

Install PHP-FPM on Debian 12

PHP-FPM (FastCGI Process Manager) is a high-performance PHP handler.

Step 1 – Install PHP-FPM

apt update && apt upgrade -y
apt install -y php8.2-fpm php8.2-cli php8.2-common php8.2-opcache php8.2-mysql php8.2-mbstring php8.2-xml php8.2-gd

Step 2 – Start and enable the service

systemctl enable --now php8.2-fpm

Step 3 – Verify

php --version
php-fpm -v 2>/dev/null || php-fpm8.3 -v 2>/dev/null || php-fpm8.2 -v

Step 4 – Key configuration file

The main pool configuration is at /etc/php/8.2/fpm/pool.d/www.conf. Important settings:

; Run as web server user
user = www-data
group = www-data

; UNIX socket (preferred over TCP for local use)
listen = /run/php-fpm/www.sock
listen.owner = www-data
listen.group = www-data

; Process management
pm = dynamic
pm.max_children = 20
pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 10
pm.max_requests = 500

Apply changes:

systemctl reload php-fpm 2>/dev/null || rc-service php-fpm reload 2>/dev/null || rcctl reload php83_fpm