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. However, you can apply this tutorial to any other 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:
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Now you can install the remi repository:
dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.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}