PHP, a widely-used programming language for dynamic web applications, has released its version 8.4, bringing new functionalities and enhancements for developers. This guide will walk you through the installation of PHP 8.4 on a RHEL 9 system. Please note that these instructions assume you are operating as the root user. If you are not, remember to use the sudo
command before each command to gain root privileges.
Step 1: Update System Packages
Begin by updating your system's package repository to ensure you have the latest package information and to install any available updates. Use the following dnf
command:
sudo dnf update
Step 2: Enable EPEL Repository in RHEL
The next step is to enable the Extra Packages for Enterprise Linux (EPEL) repository. This repository provides additional packages that are not available in the default RHEL repositories. Install the epel-release
package using these commands:
sudo subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
Step 3: Enable Remi Repository in RHEL
To access the latest PHP versions, including PHP 8.4, you need to enable the Remi repository. Remi is known for providing up-to-date PHP packages for RHEL and other systems. Enable the Remi repository by installing its release package:
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
Step 4: Install PHP 8.4 in RHEL
If you have a previous version of PHP installed, such as PHP 8.3, it's necessary to reset the PHP module to avoid conflicts during the installation of PHP 8.4. Use the following command to reset the PHP 8.3 module:
sudo dnf module reset php:remi-8.3
After resetting the PHP module, update your system's package repository again to ensure all changes are applied. Then, proceed to install PHP 8.4 along with essential extensions using the dnf module install
command:
sudo dnf update
sudo dnf module install php:remi-8.4
Once the installation is complete, verify that PHP 8.4 is correctly installed by checking the PHP version:
php -v
Step 5: Install Additional PHP Extensions (Optional)
Depending on the requirements of your web projects, you might need to install additional PHP extensions. To search for available PHP extensions, you can use the dnf search
command with a wildcard:
sudo dnf search php-*
After identifying the extensions you need, install them using dnf install
. For example, to install the php-gd
and php-xml
extensions, use:
sudo dnf install php-gd php-xml
If you are using a web server like Apache (httpd
) or Nginx, restart the web server to ensure that the newly installed PHP extensions are loaded and active:
For Apache:
sudo systemctl restart httpd
For Nginx:
sudo systemctl restart nginx
For further reading and more information about PHP, you may find these articles helpful:
How to Use and Execute PHP Codes in Linux Command Line How to Find MySQL, PHP, and Apache Configuration Files How to Test PHP MySQL Database Connection Using Script How to Run PHP Script as Normal User with Cron
Congratulations! You have successfully installed PHP 8.4 on your RHEL 9 system. You can now begin developing and deploying web applications using the latest features and improvements of PHP 8.4.
0 comments:
Post a Comment