Faruque Ahmed : MCP, MCSA, MCSE, MCTS, MCIT, CCNA, OCA, OCP, GCP
# dnf update
To install PHP 8.1, we need to add and enable the Remi RPM repositories. Before that, we also need to install the EPEL repository. Let’s start by installing the EPEL repository with the following command:
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
Next, we can install the Remi repository by running the following command:
dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
This will add the Remi repository to your system, which contains the PHP 8.1 packages that we need.
Once the Remi repository is installed, you can list the available PHP module streams by running the following command:
dnf module list php
This command will display the available PHP versions, including PHP 7.4, PHP 8.0, and PHP 8.1.
To install PHP 7.4, we can use the remi repository. Run the following command to install PHP 7.4:
dnf module install php:remi-7.4
# php -v
The command will display the PHP version installed on your system. In this case, it should show PHP 7.4.
# dnf install php-mysql php-xml pcre php-common php-mbstring php-pear php-json curl unzip -y
# dnf install php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-json php-mcrypt php-mssql php-snmp php-soap php-tidy curl curl-devel -y
Now, let’s proceed with installing PHP 8.1. Run the following command to install PHP 8.1:
dnf module install php:remi-8.1
This command will install the PHP 8.1 packages and dependencies from the Remi repository.
After the installation is complete, you can verify the installed PHP version by running the following command:
php -v
The command will display the PHP version installed on your system. This time, it should show PHP 8.1.
To keep your system up-to-date and install any necessary packages, you can run the following command:
dnf update