Introduction
The PHP programming language is one of the most widely used server-side programming languages. It is a language used to develop dynamic and responsive websites.
In this guide, we will show how to install PHP 8.3 on AlmaLinux 8 and 9 versions. However, you can apply this tutorial to any other PHP version.
Installation guide
Step for AlmaLinux 8 only: Import GPG key repository
This step is for AlmaLinux 8 only. Skip this step on CentOS 7.
Run the following command to install updated GPG keys on AlmaLinux 8:
rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux
1. Update the system
Make sure to check if there are any updates available:
dnf check-update
If yes, run the following command to update the system:
yum update -y
After that, reboot the system:
reboot
2. Add remi RPM repository
For PHP, we also need to install EPEL.
On AlmaLinux 8, follow these steps:
Run the following command:
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Install the remi repository:
dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.rpm
The same procedure is for AlmaLinux 9, just run these commands:
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
dnf -y install http://rpms.remirepo.net/enterprise/remi-release-9.rpm
After that, update DNF cache with the following command:
dnf makecache -y
3. Reset default PHP module
Before installing PHP, make sure to reset the default PHP module by running this command:
dnf module reset php -y
4. Install the PHP
To install PHP, run the following command (you can install any other version; just type a different number instead of 8.3):
dnf module install php:remi-8.3
After that, run this command to complete the installation:
dnf -y install php
5. Check PHP
To check if PHP was installed successfully, you can run this command, which will provide information about the installed version:
php -v
PHP extensions
To list all the available PHP extensions, run the following command:
php -m
To install the PHP extension, you need to run the dnf install command in the following format (change the "extension_name" to the actual extension):
dnf install php-extension_name
To install multiple extensions, run this command in the following format:
dnf install php-{common,pear,cgi,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap}