Install PHP 8.1 In Debian 9, 10, and Debian 11

,

PHP is the most widely used programming language on the web. PHP 7 was released with a slew of new features and performance enhancements, and its successor, PHP 8, is even better. PHP 8.1.x is the most recent PHP build, released earlier this year.

If you are starting a new PHP project, it is highly recommended that you have the most recent version installed. If not, we’ll show you how to upgrade to PHP 8.1 in Debian 9, 10, or 11. If you’re using Ubuntu, check out this article on how to install/upgrade to the most recent PHP version in Ubuntu or derivatives.

If your PHP application is built upon an older PHP version, make sure that it supports the latest . WordPress, the most popular content management system and Laravel, a great PHP framework supports PHP 8.

Pre-requisites

Before installation begins, make sure to run the following command to install pre-requisites to installing PHP 8.

sudo apt install apt-transport-https lsb-release ca-certificates wget -y
Install PHP pre requisites
Install PHP pre requisites

Add GPG key and Sury repository –

sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
Add GPG key
Add GPG key
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

Update repositories –

sudo apt update

Now Ondrej Sury PHP repository added to the operating system. After updating the local repositories, we can install the latest PHP version. At the time of writing this article, PHP 8.1.x is the latest version. If you have an older PHP version installed, then upgrade to get the latest version.

sudo apt upgrade -y

Install PHP 8 in Debian

sudo apt install php8.1
Install PHP.
Install PHP.

Install PHP 8 with Apache support

Apache is the most popular web server. If you plan to setup your application on Apache, then use the following command –

sudo apt install php8.1 libapache2-mod-php8.1

Install PHP 8 with Nginx support

Nginx is the best alternative to Apache. If you plan to set up your application on Nginx, then use the following command –

sudo apt install php8.1 php8.1-fpm php8.1-cli -y

Conclusion

You can use this article to install PHP 8 on Debian 9, Debian 10, and Debian 11. If you’re upgrading a production server, make sure to read this guide first. Finally, your application must support PHP 8, or else it may encounter issues.


Our Trusted Hosting Services

contabo vps
MassiveGRID Banner

Leave a Reply

Your email address will not be published.