Debian Linux distribution is stable so it is common that most packages it shipped with will be not latest and that’s the reason we’ll be installing latest PHP on Debian. See how:
1. Update the system once.
sudo apt update
2. Install needed packages.
sudo apt install apt-transport-https lsb-release ca-certificates curl -y
3. Using deb.sury.org DPA and adding it to source list.
sudo curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
4. Update the system once again.
sudo apt update
5. Now install any version of PHP.
Here we will be install latest PHP8.2 for a demonstration:
sudo apt install php8.2-fpm php8.2-common php8.2-mysql php8.2-zip
Or you can install like this too:
sudo apt install php8.2-{fpm,common,mysql,zip}
It will work both the way.
6. Simply start and enable PHP to use.
sudo systemctl start php8.2-fpm
sudo systemctl enable php8.2-fpm
Now we have installed latest PHP on Debian system.
Leave a Reply