Image

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

[Virtual servers]
Date of publication: 06.12.2022

In this guide, we will upgrade php 7.4 to php 8.1 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.1 and php8.1-fpm

apt update
apt upgrade
apt install php8.1-fpm
apt install php8.1-common php8.1-mysql php8.1-xml php8.1-xmlrpc php8.1-curl php8.1-gd php8.1-imagick php8.1-cli php8.1-dev php8.1-imap php8.1-mbstring php8.1-opcache php8.1-soap php8.1-zip php8.1-redis php8.1-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.1-fpm.sock;

Restart the services and also disable the old php7.4-fpm if available and enable the new php8.1-fpm

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

Done, setup completed.





No Comments Yet