Installing latest PHP on Debian

Published on


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:

PHP on Debian

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 DPA and adding it to source list.

sudo curl -sSLo /usr/share/keyrings/
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/] $(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.

Published in: .

Leave a Reply

Your email address will not be published. Required fields are marked *