How to install or upgrade to PHP 8.3 on Ubuntu, Debian, Fedora, RHEL, CentOS

How to install or upgrade to PHP 8.3 on Ubuntu, Debian, Fedora, RHEL, CentOS

How to install or upgrade to PHP 8.3 on Ubuntu and Debian.webp


PHP 8.3 is 2023's major new update to PHP. It brings nice new features such as typed class constants, a new set of Exceptions in DateTime extension, a new json_validate function, and a handful of new features, changes, and deprecations. As always, PHP 8.3 brings several bug fixes and improvements as well as performance improvements.

This article explains how to install PHP 8.3 on modern Ubuntu, Debian, Fedora, RHEL, CentOS systems. Some of the most popular PECL extensions are also available to install in a similar way, which are listed in the Installing PECL Extensions section.

Install PHP 8.3 on Debian (10, 11, and 12)
Bash:
# Save existing php package list to packages.txt file
sudo dpkg -l | grep php | tee packages.txt

# Add Ondrej's repo source and signing key along with dependencies
sudo apt install apt-transport-https
sudo curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update

# Install new PHP 8.3 packages
sudo apt install php8.3 php8.3-cli php8.3-{bz2,curl,mbstring,intl}

# Install FPM OR Apache module
sudo apt install php8.3-fpm
# OR
# sudo apt install libapache2-mod-php8.3

# On Apache: Enable PHP 8.3 FPM
sudo a2enconf php8.3-fpm
# When upgrading from an older PHP version:
sudo a2disconf php8.2-fpm

# Remove old packages
sudo apt purge php8.2*

Install PHP 8.3 on Ubuntu (20.04, 22.04, and 24.04)
Bash:
## Save existing php package list to packages.txt file
sudo dpkg -l | grep php | tee packages.txt

# Add Ondrej's PPA
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update

# Install new PHP 8.3 packages
sudo apt install php8.3 php8.3-cli php8.3-{bz2,curl,mbstring,intl}

# Install FPM OR Apache module
sudo apt install php8.3-fpm
# OR
# sudo apt install libapache2-mod-php8.2

# On Apache: Enable PHP 8.3 FPM
sudo a2enconf php8.3-fpm
# When upgrading from an older PHP version:
sudo a2disconf php8.2-fpm

## Remove old packages
sudo apt purge php8.2*

Install PHP 8.3 on Fedora 37, 38, and 39
Bash:
# Save existing php package list to packages.txt file
sudo dnf list installed | grep php | tee packages.txt

# Add Remi's repo
sudo dnf install https://rpms.remirepo.net/fedora/remi-release-$(cut -d ' ' -f 3 /etc/fedora-release).rpm
sudo dnf config-manager --set-enabled remi

# Install new PHP 8.3 packages
sudo dnf install php83 php83-php-fpm

# Remove old packages
sudo dnf remove php82*

# Create symlinks from `php` to actual PHP binary
sudo dnf install php83-syspaths -y

Install PHP 8.3 on RHEL/Alma/Rocky/CentOS Stream/etc
Bash:
# Save existing php package list to packages.txt file
sudo dnf list installed | grep php | tee packages.txt

# Add Remi's repo
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(cut -d ' ' -f 4 /etc/redhat-release | cut -d '.' -f 1).noarch.rpm -y
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-$(cut -d ' ' -f 4 /etc/redhat-release | cut -d '.' -f 1).rpm -y

# Install new PHP 8.3 packages
sudo dnf install php83 php83-php-fpm

# Remove old packages
sudo dnf remove php82*

# Create symlinks from `php` to actual PHP binary
sudo dnf install php83-syspaths -y
 
Top