To install PHP 7.4 on AlmaLinux 9, follow the steps below:
Step 1 : Update System Packages
Before installing PHP, update your system to ensure all packages are up to date:
Step 2 : Import PHP Remi Repository
Remi is the official repository that provides PHP packages for RHEL-based distributions like AlmaLinux. Install it using:
Step 3 : Check Available PHP Modules
Verify the available PHP modules in the system:
Step 4 : Enable PHP 7.4 from Remi Repository
By default, AlmaLinux provides newer PHP versions. Enable PHP 7.4 explicitly:
Step 5 : Install PHP Core Components
Now, install PHP 7.4 and its essential components:
Step 6 : Install Commonly Used PHP Extensions
For better compatibility, install the necessary PHP extensions:
- php-mysqlnd – MySQL native driver for PHP
- php-curl – Enables data transfer with URLs
- php-gd – Image processing library
- php-mcrypt – Provides encryption support
- php-json – Handles JSON data
- php-pear – PHP Extension and Application Repository
- php-common – Common PHP libraries
- php-xml – XML processing support
- php-zip – ZIP archive support
- php-devel – Development files for PHP
- php-xsl – Extensible Stylesheet Language support
- php-soap – SOAP protocol support
- php-bcmath – Arbitrary precision mathematics
- php-mbstring – Multi-byte string handling
- php-gettext – Translation and localization support
- php-imagick – ImageMagick extension for image manipulation
Step 7 : Verify PHP Installation
Check the installed PHP version:
If everything is set up correctly, you should see output showing PHP 7.4.
Congratulations! You have successfully installed PHP 7.4 on AlmaLinux 9.