How to upgrade PHP to 8.1 in Debian?
Upgrade PHP to 8.1 in the Debian 9, 10, and 11 servers
1. Run the below commands in the Debian server
rootdebian:~$ apt install -y lsb-release apt-transport-https ca-certificates wget
rootdebian:~$ wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
rootdebian:~$ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
2. Run the below to update outdated packages and install PHP 8.1
rootdebian:~$ apt update
rootdebian:~$ apt install php8.1 -y
3. Run the below command to install 8.1 modules
rootdebian:~$ apt install php8.1-cli php8.1-xml php8.1-gd php8.1-curl php8.1-mysql php8.1-ldap php8.1-zip -y
4. Run the below command to confirm PHP 8.1 has been successfully installed in the Debian server
rootdebian:~$ php -v
5. Add a PHP info page to confirm 8.1 has loaded for the webserver.
rootdebian:~$ vim /var/www/html/phpinfo.php
<?php
phpinfo();
?>
Related Articles
How to upgrade PHP to 7.4 on Centos 7?
How to upgrade PHP to 8.1 in Ubuntu?
How to install and switch different versions of PHP in Ubuntu?