PHP 8.5 has been released and upgrading the server is very important because every time PHP updates, it brings better software compatibility, security and performance. If you are still using the older versions of PHP, i would suggest you to update the PHP version to 8.5.
In this tutorial i will guide you how to install PHP 8.5 on Ubuntu 24.04. You can also try installing PHP 8.5 on Debian 13 Trixie with this tutorial.
We will use Ondřej Surý PPA as it is the most trusted third party source other than the official repository.
Prerequisites
- A server with Ubuntu 24.04 installed
- A user with sudo privileges
Step 1 – Updating the System
As always, the first step is to update the system. So lets first update our Ubuntu 24.04
sudo apt update
sudi apt upgrade -y
Step 2 – Installing dependencies
Next step is to install the required dependencies. Just execute the given below commands
sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https -y
Step 3 – Adding Ondřej Surý repository
As i have explained above, we will use Ondřej Surý repository to install PHP 8.5
sudo add-apt-repository ppa:ondrej/php
Lets update the packages again
sudo apt update -y
Step 4 – Installing PHP common extensions
In this last step we will install the common PHP extensions that will be needed by almost all the setups
sudo apt install php8.5-fpm php8.5-mysql php8.5-curl php8.5-bcmath php8.5-mbstring php8.5-xml php8.5-zip php8.5-gd php8.5-imagick php8.5-intl -y
As the installation completes, lets verify the installation. You can use either of the two commands to verify the PHP version
php -v
Or
php8.5 --version
Step 5 – Enable PHP 8.5
The final step is to enable PHP
sudo systemctl enable php8.5-fpm
Conclusion
With this you have successfully installed PHP 8.5 on your Ubuntu 24.04 server. Remember that this is the most suitable method because later in future if you want to update from PHP 8.5 to the next version, you dont again have to add the Ondřej Surý repository, you just have to remove the PHP packages and install the PHP with next version.