Introduction
PHP is one of the most popular server-side programming languages, widely used for developing dynamic and responsive websites.
This guide will walk you through installing PHP 8.3 on AlmaLinux 8 and 9. The steps provided can be applied to other PHP versions as well
Installation guide
Step for AlmaLinux 8 only: Import GPG key repository
If you're using AlmaLinux 8, begin by importing the updated GPG keys. This step is unnecessary for CentOS 7 users.
Use the following command to import the GPG key on AlmaLinux 8:
rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux
1. Update the System
First, check for any available updates:
dnf check-update
If updates are available, update your system with:
yum update -y
After the update is complete, reboot the system:
reboot
2. Add the Remi RPM Repository
To proceed with installing PHP, you'll need to install the EPEL repository.
For AlmaLinux 8, run the following commands:
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.rpm
After installing the repositories, update the DNF cache:
dnf makecache -y
3. Reset the Default PHP Module
Before installing PHP, reset the default PHP module with this command:
dnf module reset php -y
4. Install PHP
To install PHP 8.3 (or any other version, just replace the version number), run:
dnf module install php:remi-8.3
After that, complete the installation with:
dnf -y install php
5. Verify PHP Installation
To verify that PHP was installed successfully, check the version with:
php -v
PHP Extensions
To list all available PHP extensions, use:
php -m
To install a specific PHP extension, use the following command format, replacing "extension_name" with the actual name of the extension:
dnf install php-extension_name
For multiple extensions, use this format:
dnf install php-
{common,pear,cgi,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap}