Overview
PHP is a highly popular server-side scripting language used extensively for creating dynamic and interactive websites.
This tutorial will cover the steps to install PHP 8.3 on AlmaLinux 8. However, the instructions can be adapted for other versions as well.
Installation Steps
Step for AlmaLinux 8 Only: Import GPG Key Repository
1. Update The System
- First, check for any available updates:
dnf check-update
- If updates are available, update the system with:
yum update -y
reboot
2. Add Remi RPM Repository
- You will need to install EPEL for PHP:
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
- Next, install the Remi repository:
dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.rpm
3. Reset Default PHP Module
- Before proceeding with the PHP installation, reset the default PHP module:
dnf module reset php -y
4. Install PHP
- To install PHP, use the following command (replace "8.3" with the desired version number if different):
dnf module install php:remi-8.3
- Complete the installation with:
dnf -y install php
5. Verify PHP Installation
- To ensure PHP was installed correctly, run:
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
- To install multiple extensions simultaneously, use the following format:
dnf install php-{common,pear,cgi,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap}