Commit

58d4df7

One of the challenges Linux users face is upgrading PHP to newer versions. Even with older versions such as version 26 and earlier registering and configuring PHP repositories (mirrors) can sometimes prove difficult. For this reason, in this post, we will explore how to upgrade PHP to newer versions on Linux and provide solutions for potential issues that may arise. 1. First, retrieve the repository's signing key from the Ubuntu Keyserver and verify it:
bash
sudo apt install -y curl ca-certificates gnupg
bash
sudo mkdir -p /etc/apt/keyrings
bash
curl -fsSL 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB8DC7E53946656EFBCE4C1DD71DAEAAB4AD4CAB6' \
  | gpg --dearmor \
  | sudo tee /etc/apt/keyrings/ondrej-php.gpg >/dev/null
2. Add the repository for Ubuntu 24.04:
bash
echo "deb [signed-by=/etc/apt/keyrings/ondrej-php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble main" \
  | sudo tee /etc/apt/sources.list.d/ondrej-php.list
3. Update the package list and check access:
bash
sudo apt update
apt-cache policy php8.5-common
4. If Candidate shows a version of PHP 8.5, install it:
bash
sudo apt install -y php8.5-cli php8.5-common php8.5-bcmath php8.5-bz2 php8.5-curl php8.5-gd php8.5-gmp php8.5-intl php8.5-mbstring php8.5-readline php8.5-xml php8.5-zip
5. Final Review:
bash
php8.5 -v
php8.5 -m
6. If you want PHP 8.5 to be the default version
bash
sudo update-alternatives --config php
If the PHP 8.5 option appears, select the corresponding number. Good luck.

commit 58d4df7