To install PHP 8.1 on AlmaLinux 9, follow these steps:
Step 1 : Update System Packages
Before installing PHP, update your system packages:
Step 2 : Import PHP Remi Repository
The Remi repository provides the latest PHP versions for RHEL-based distributions. Install it with:
Step 3 : Check Available PHP Modules
Verify the available PHP modules before enabling PHP 8.1:
Step 4 : Enable PHP 8.1 from Remi Repository
Enable PHP 8.1 by resetting the default PHP module and setting it to Remi's PHP 8.1:
Step 5 : Install PHP Core Packages
Now, install PHP 8.1 along with its FPM and CLI components:
Step 6 : Install Commonly Used PHP Extensions
To enhance PHP functionality, install these commonly used extensions:
- php-mysqlnd – Enables MySQL database support
- php-curl – Allows PHP to interact with URLs and APIs
- php-gd – Provides image processing functions
- php-mcrypt – Adds encryption support
- php-json – Enables JSON data handling
- php-pear – Manages PHP package dependencies
- php-common – Includes shared PHP files
- php-xml – Adds support for XML parsing
- php-zip – Provides ZIP file handling
- php-devel – Includes development tools for PHP
- php-xsl – Enables XSLT transformations
- php-soap – Supports SOAP-based web services
- php-bcmath – Adds support for arbitrary precision math
- php-mbstring – Handles multibyte string encoding
- php-gettext – Enables internationalization support
- php-imagick – Provides image manipulation functions
Step 7 : Verify Installation
Check the installed PHP version to confirm the setup:
Congratulations! You have successfully installed PHP 8.1 on AlmaLinux 9.