How to Install PHP 8.5 on Debian 12

PHP is a widely used open-source scripting language primarily designed for web development.
It can be embedded into HTML and works with many databases and frameworks.

In this guide, we will show you how to install PHP 8.5 on Debian 12 (Bookworm).


Prerequisites

  • A system running Debian 12
  • Root access or a user with sudo privileges

Step 1: Connect to your Server

Connect to your server via SSH.

ssh root@your_server_ip

Replace your_server_ip with the IP address of your server.


Step 2: Update the System

Update the package list and upgrade installed packages.

apt update && apt upgrade -y

Step 3: Install curl

The curl utility is required to download the PHP repository key.
If you encounter curl: command not found, install it using:

apt install curl -y

Step 4: Install Required Dependencies

Install additional packages required for adding external repositories.

apt install ca-certificates gnupg lsb-release -y

Step 5: Add the PHP Repository

Debian's default repositories may not contain the latest PHP versions.
We will add the Sury PHP repository, which provides updated PHP packages.

Download and add the repository GPG key:

curl -fsSL https://packages.sury.org/php/apt.gpg -o /usr/share/keyrings/sury-php.gpg

Add the repository to the system:

echo "deb [signed-by=/usr/share/keyrings/sury-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list

Update the package index:

apt update

Step 6: Install PHP 8.5

Install PHP 8.5 with the following command:

apt install php8.5 -y

Step 7: Install Common PHP Extensions

Install commonly used PHP extensions required by many applications:

apt install php8.5-cli php8.5-common php8.5-curl php8.5-mbstring php8.5-xml php8.5-zip php8.5-gd php8.5-intl php8.5-mysql -y

Step 8: Verify PHP Installation

Check the installed PHP version:

php -v

Example output:

PHP 8.5.3 (cli) (built: Feb 13 2026 15:52:21) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.5.3, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.3, Copyright (c), by Zend Technologies

Step 9: Install PHP-FPM (Optional)

If you are using Nginx or Apache with PHP-FPM, install the PHP-FPM service:

apt install php8.5-fpm -y

Enable and start the service:

systemctl enable php8.5-fpm
systemctl start php8.5-fpm

Check the service status:

systemctl status php8.5-fpm

Conclusion

You have successfully installed PHP 8.5 on Debian 12.
You can now configure your web server (Apache or Nginx) to use PHP and start deploying PHP-based applications.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS