Upgrading PHP on Debian 11 and Ubuntu 22.04 using Ondrej
For Debian 11 and Ubuntu 22.04 users who prefer to update PHP rather than migrate to a new server, here’s how to install PHP 8.2 using Ondřej Surý’s repository:
First, make sure you have a backup of your system prior to the update and let’s make now sure your system is up to date:
sudo apt update
sudo apt upgrade
Add the GPG key for the Ondřej’s repository:
curl -fsSL https://packages.sury.org/php/apt.gpg | sudo gpg --dearmor -o /usr/share/keyrings/php-archive-keyring.gpg
Add the repository to your sources list:
echo "deb [signed-by=/usr/share/keyrings/php-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
Update package lists with the new repository included:
sudo apt update
Install PHP 8.2 and the extensions needed for passbolt:
sudo apt install -y php8.2 php8.2-cli php8.2-common php8.2-curl php8.2-fpm php8.2-gd php8.2-intl php8.2-mbstring php8.2-mysql php8.2-opcache php8.2-xml php8.2-gnupg php8.2-pgsql php8.2-ldap
Verify that PHP 8.2 is now installed:
php8.2 -v
Configure the system to use PHP 8.2 as the default PHP version:
sudo update-alternatives --set php /usr/bin/php8.2
Verify that PHP 8.2 is now the default version:
php -v
Configure PHP-FPM to start automatically and restart the service:
sudo systemctl enable php8.2-fpm
sudo systemctl start php8.2-fpm
If you’re using Nginx, update your configuration to use PHP 8.2-FPM:
# Edit your passbolt nginx configuration
sudo nano /etc/nginx/sites-enabled/nginx-passbolt.conf
# Change the PHP-FPM socket path if necessary
# From: fastcgi_pass unix:/run/php/php7.4-fpm.sock;
# To: fastcgi_pass unix:/run/php/php8.2-fpm.sock;
Test your Nginx configuration:
sudo nginx -t
If the test is successful, restart Nginx:
sudo systemctl restart nginx
Voilà!