Install PHP 8.3 and PHP-FPM on Debian 12
Install PHP 8.3 on Debian 12
apt update && apt install -y wget gnupg2 lsb-release
wget https://packages.sury.org/php/apt.gpg && apt-key add apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
apt install -y php8.3
After installation check php version
php -v
Install PHP-FPM and Extensions
If you also want to install additional modules, then first write the command in the terminal
apt-cache search php8.3
Then select the modules you need and and write in the terminal
apt-get install -y php8.3-fpm php8.3-cli php8.3-curl php8.3-mysql php8.3-sqlite3 php8.3-gd php8.3-xml php8.3-mcrypt php8.3-mbstring php8.3-iconv php8.3-cgi php8.3-gd php8.3-zip
Enable PHP-FPM
systemctl enable php8.3-fpm
Start the PHP-FPM
systemctl start php8.3-fpm
Check PHP-FPM status
service php8.3-fpm status
Result
php8.3-fpm.service - The PHP 8.3 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php8.3-fpm.service; enabled; preset: ena>
Active: active (running) since Sat 2025-01-11 08:35:26 EST; 1min 31s ago
Docs: man:php-fpm8.3(8)
Configure PHP-FPM
Open php.ini file
nano /etc/php/8.3/fpm/php.ini
and set
cgi.fix_pathinfo=0
Open PHP-FPM configuration file www.conf
nano /etc/php/8.3/fpm/pool.d/www.conf
And set www-data value for user, group, listen.owner, listen.group
user = www-data
group = www-data
listen.owner = www-data
listen.group = www-data
Save and restart PHP-FPM
service php8.3-fpm restart
Now open the file nginx.conf
nano /etc/nginx/nginx.conf
And in the first line replace
user nginx;
replace with
user www-data;
Restart the server
service nginx restart