In this blog article, I want to show you how to install PHP 8 on Debian 9/10/11.
First, we log in to the server via SSH, e.g. with Putty.
Now we run the following command:
- Update the server:
root@testserver ~ # apt update - Install the required packages:
root@testserver ~ # apt install sudo lsb-release ca-certificates apt-transport-https software-properties-common -y - Download and add the public key for the repository:
root@testserver ~ # wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add - - Add the repository:
root@testserver ~ # echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list - Update the server:
root@testserver ~ # apt update - Install PHP 7.4:
root@testserver ~ # apt install php8.0 -y
Now we can check the PHP version with the following command:
root@testserver:~# php -v
PHP 7.8.0 (cli) (built: Jun 30 2021 20:40:09) ( NTS )
Copyright (c) The PHP Group
Frequently asked questions
How do I update the server before installing PHP?
Run apt update to refresh the package lists.
Where does the PHP 8 package come from?
From the Sury repository, added via its public key and an entry in /etc/apt/sources.list.d/sury-php.list.
How do I check which PHP version is installed?
Run php -v on the server.