Tutorials  /  Ubuntu

Install PHP 8.4 with PHP-FPM on Debian 12 and Apache

Ccentron Redaktion · August 2025 ·5 min read ·Ubuntu, Tutorial

PHP (Hypertext Preprocessor) is an open-source server-side scripting language widely used to create interactive websites and web applications. The PHP 8.x series delivers major performance boosts, introducing features such as Just-In-Time (JIT) compilation, named arguments, and union types that modernize the development workflow and improve efficiency.

This guide explains how to install PHP 8.4 on Debian 12, configure PHP-FPM for better request handling, and integrate it with the Apache web server.

Prerequisites

  • A Debian 12 server
  • Access as a non-root user with sudo privileges
VM

Matching infrastructure at centron

Ubuntu servers without your own hardware: ccloud³ VMs with full root access from €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Add the PHP PPA Repository

Debian 12’s default APT repositories may not always provide the newest PHP versions. The SURY repository, maintained by Ondřej Surý (Debian’s PHP package maintainer), offers updated and trusted PHP builds.

First, update your system and upgrade packages:

Console
$ sudo apt update && sudo apt upgrade -y

Install essential dependencies:

Console
$ sudo apt install -y lsb-release apt-transport-https ca-certificates

Import the SURY GPG key for repository validation:

Console
$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Add the SURY repository to your APT sources:

Console
$ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Refresh the package index again:

Console
$ sudo apt update -y

Check available PHP versions in the repository:

Console
$ sudo apt policy php

Output shows PHP 8.4 available from the SURY repository.

Install PHP 8.4

Install PHP 8.4 with common extensions required for database connectivity, string manipulation, and API communication.

Console
$ sudo apt install -y php8.4

Verify installation:

Console
$ php8.4 -v

List installed versions:

Console
$ ls /etc/php

If PHP 8.4 is the only version installed, set it as the default:

Console
$ sudo update-alternatives --install /usr/bin/php php /usr/bin/php8.4 84

Then confirm:

Console
$ php -v

Install common PHP extensions:

Console
$ sudo apt install -y php8.4-mysql php8.4-curl php8.4-xml php8.4-mbstring
  • php8.4-mysql: Database connectivity for MySQL/MariaDB
  • php8.4-curl: Remote data fetching
  • php8.4-xml: XML parsing support
  • php8.4-mbstring: Multibyte string handling for UTF-8

Verify active PHP modules:

Console
$ php8.4 -m

Install PHP-FPM 8.4

PHP-FPM (FastCGI Process Manager) separates PHP execution from the web server for better scalability and performance.

Install PHP-FPM:

Console
$ sudo apt install -y php8.4-fpm

Edit the pool configuration file:

Console
$ sudo nano /etc/php/8.4/fpm/pool.d/www.conf

Set the socket PHP-FPM will use:

Code
listen = /run/php/php8.4-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660

Enable PHP-FPM on boot:

Console
$ sudo systemctl enable php8.4-fpm

Restart PHP-FPM:

Console
$ sudo systemctl restart php8.4-fpm

Check service status:

Console
$ sudo systemctl status php8.4-fpm

Test and Use PHP with Apache

Now connect PHP-FPM with Apache using proxy_fcgi.

Install Apache:

Console
$ sudo apt install -y apache2

Enable required modules:

Console
$ sudo a2enmod proxy_fcgi setenvif
$ sudo a2enconf php8.4-fpm

Restart Apache:

Console
$ sudo systemctl restart apache2

Create a sample PHP file:

Console
$ sudo nano /var/www/html/sample.php

Insert:

Code
<!--?php phpinfo(); ?-->

Allow firewall access:

Console
$ sudo ufw allow 80/tcp
$ sudo ufw reload

Visit http://SERVER-IP/sample.php in a browser to confirm PHP is working.

Conclusion

You have successfully installed PHP 8.4 and PHP-FPM on Debian 12, configured Apache integration, and tested the setup with a sample script. This environment is now ready for deploying modern PHP-based applications. For additional configuration and performance tuning, refer to the official PHP documentation.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Ubuntu
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren