Upgrade or Install PHP 8.2 on Debian running Apache2


1. Updating Debian as root

$ su - 
$ apt update
$ apt upgrade -y && reboot

 

2. Add SURY PHP PPA Repository

$ apt -y install lsb-release apt-transport-https ca-certificates wget $ wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 

$ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list

3. Installing PHP 8.2 on Debian

$ apt update

$ apt -y install php8.2

$ update-alternatives –set php /usr/bin/php8.2

4. Install Important Modules for PHP 8.2 on Debian

$ apt -y install php8.2-cli php8.2-curl php8.2-gd php8.2-intl php8.2-mbstring php8.2-mysql php8.2-opcache php8.2-readline php8.2-xml php8.2-xsl php8.2-zip php8.2-bz2

5. Making PHP 8.2 module for Apache available

$ apt -y install libapache2-mod-php8.2

$ systemctl reload apache2

Finish! the installation is done. If you want to know which installed PHP version and modules are actually available, the next section shows.

$ php -v 

PHP 8.2.13 (cli) (built: Nov 24 2023 13:09:20) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.13, Copyright (c) Zend Technologies
with Zend OPcache v8.2.13, Copyright (c), by Zend Technologies

 

 

Leave a comment