Image

Knowledge base → Installing or upgrading php 7.4 to php 8.2 on Linux Debian 11

[Virtual servers]
Date of publication: 04.12.2022

In this guide, we will upgrade php 7.4 to php 8.2 on Linux Debian 11 operating system. If you install php from scratch, the steps will be similar. In this example, we use php-fpm in conjunction with nginx as a web server.

1. Let's connect the 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" | sudo tee /etc/apt/sources.list.d/php.list

2. Update packages and install php 8.2 and php8.2-fpm

apt update
apt upgrade
apt install php8.2-fpm
apt install php8.2-common php8.2-mysql php8.2-xml php8.2-xmlrpc php8.2-curl php8.2-gd php8.2-imagick php8.2-cli php8.2-dev php8.2-imap php8.2-mbstring php8.2-opcache php8.2-soap php8.2-zip php8.2-redis php8.2-intl

3. Let's make changes to the nginx configuration file

/etc/nginx/conf.d/domain.tld.conf

Let's find the line:

fastcgi_pass unix:/run/php/php7.4-fpm.sock;

Let's replace it with:

fastcgi_pass unix:/run/php/php8.2-fpm.sock;

Restart the services and also turn off the old php7.4-fpm if available and turn on the new php8.2-fpm

systemctl disable php7.4-fpm
systemctl enable php8.2-fpm
systemctl stop php7.4-fpm
systemctl restart php8.2-fpm
service nginx restart

Done, setup completed.





No Comments Yet