How to Install PHP 8 on Debian 12
PHP 8.2 is a major update of the PHP language. It contains many new features, including readonly classes, null, false, and true as stand-alone types, deprecated dynamic properties, performance improvements and more.
Update the System
Update the Debian 12 using the following command.
apt update
To Add SURY PHP PPA repository.
First, download the GPG key.
apt -y install lsb-release apt-transport-https ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
Next, add SURY to the repository.
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
Output:
root@server:~# echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
deb https://packages.sury.org/php/ bullseye main
Install PHP 8.2
Ensure the added package is up to date.
apt update
If any update is available update the system and reboot.
apt upgrade -y && reboot
To install PHP 8.2
apt -y install php8.2
Output:
root@vps:~# apt -y install php8.2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php8.2 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
libcurl4 liblua5.3-0 libsodium23 php-common php8.2-cli php8.2-common php8.2-opcache php8.2-readline psmisc ssl-cert
To check the PHP version.
php -v
Output:
root@vps:~# php -v
PHP 8.2.7 (cli) (built: Jun 9 2023 07:38:17) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies
root@vps:~#
Installing PHP Extensions
Install PHP Extensions by running the following command
apt install php8.2-<extension>
NOTE: Replace the required extensions name like below command
apt install php8.2-apcu
Output:
root@vps:~# apt install php8.2-apcu
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
php-gd
The following NEW packages will be installed:
php8.2-apcu
To list installed php modules/extensions.
php -m
NOTE
PHP configurations related to Apache is stored in
/etc/php/8.2/apache2/php.ini
this file.- If you want to use PHP with Nginx you can follow this guide Click here.
This concludes our topic of installing PHP 8.2 on the Debian 12 system.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS