Recently, while setting up a new LEMP server for WordPress, I needed PHP 8.5. Since Debian 13 doesn’t include PHP 8.5 by default, I used Sury’s trusted repository. In this tutorial I’ll show you the exact steps I followed to install PHP 8.5 on Debian 13 Trixie.
Table of Contents
- Why PHP 8.5 and not PHP 8.4
- Prerequisites
- Step 1 – Connect to the Server with SSH
- Step 2 – Updating the Server Repository
- Step 3 – Installing curl command
- Step 4 – Installing Required Packages
- Step 5 – Adding Ondřej Surý's Repository for PHP
- Step 6 – Updating the Repository
- Step 7 – Installing PHP packages for WordPress
- Step 8 – Testing
- Conclusion
Why PHP 8.5 and not PHP 8.4
Every time PHP updates, we get compatibility improvements, security fixes, bug fixes, and better performance. To keep our websites, CMSs, and databases running smoothly and securely, it’s recommended to use the latest supported PHP version. When it comes to frameworks and CMS, updating PHP version from 8.4 to 8.5 can provide measurable performance improvements depending on your workload especially on high-traffic websites.
So let’s see how I installed PHP 8.5 on Debian 13
Prerequisites
- A VPS server with Debian 13 installed
- A user with sudo privileges or root access
Step 1 – Connect to the Server with SSH
The first step is to connect to the Debian 13 server with SSH. You can use PuTTY or you can directly enter the below command on your Windows Terminal or Command Prompt or in a Linux terminal.
ssh root@your_server_ip
Note: You can change "root" to your sudo user for example ashish. Also make sure to change "your_server_ip" to your server's IP.
Step 2 – Updating the Server Repository
In this step, we will update our Debian 13 server’s repository to the latest.
sudo apt update -y
sudo apt upgrade -y
Step 3 – Installing curl command
The curl command allows us to download files from the internet. When running the given below command if you get “command not found” error, you must first install “curl” command. In my case I encountered the same issue so I installed the curl command by executing the given below command.
sudo apt install curl -y
Step 4 – Installing Required Packages
Before installing PHP 8.5 from external repository, we need to install the required packages.
sudo apt install ca-certificates gnupg lsb-release -y
Step 5 – Adding Ondřej Surý’s Repository for PHP
Debian 13 Trixie doesn’t include the latest PHP version by default, so we will use the trusted Ondřej Surý’s PHP repository which is widely used.
curl -fsSL https://packages.sury.org/php/apt.gpg -o /usr/share/keyrings/sury-php.gpg
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
Note: Always add repositories from trusted sources. The Sury repository is maintained by Debian developer Ondřej Surý and is widely trusted for providing up-to-date PHP packages.
Step 6 – Updating the Repository
Since we have added a third party repository to our server, let’s update our server for the changes to take effect
sudo apt update
Step 7 – Installing PHP packages for WordPress
Now that the repository has been added, let’s install PHP 8.5 and the extensions required for WordPress. Even if you are not using WordPress, you can follow the above steps to install PHP 8.5 on your server for various purposes and you can install PHP 8.5 extensions according to your requirements.
sudo apt install php8.5-fpm php8.5-mysql php8.5-mysqlnd php8.5-bcmath php8.5-xml php8.5-intl php8.5-curl php8.5-gd php8.5-imagick php8.5-mbstring php8.5-zip -y
Let’s check the PHP version
php -v
Step 8 – Testing
In the final step, let’s verify that PHP-FPM service is running correctly
sudo systemctl status php8.5-fpm
If the service is active (running), the installation was successful.
Conclusion
You have now successfully installed PHP 8.5 on Debian 13 using the Sury repository. Since I am installing PHP 8.5 for WordPress, I have installed packages according to that. You can choose to install the PHP extensions required by your application.
Leave a Reply