CentOS

How to Install PHP 7.4 on CentOS 8

How to Install PHP 7.4 on CentOS 8

PHP (Hypertext Preprocessor) is the most commonly used server-side scripting language that is used to create dynamic websites. All most popular CMS (Content Management Systems) and frameworks such as WordPress, Laravel, and Magento are built in PHP programming.  You will explore in this guide how you can install PHP 7.4 version on CentOS 8 system. Different PHP versions are available for installation on CentOS 8. Before choosing a PHP version for installation from all of them, make sure this version must meet the application requirements.

Installation of PHP on CentOS 8

To install the PHP on CentOS 8 system, you require performing the following steps:

Step 1: Enable Remi repository

In CentOS 8, the PHP 7.2 version is used as the default version that supports most of the modern web applications. However, based on your application support, you can install the latest available PHP version on your system using the Remi repository. So, if you need to install PHP 7.3 or 7.4 then, by executing the following command enable the Remi repository:

$ sudo yum install yum-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

After running the above command, the EPEL repository will also be enabled on your system.

Once the repository is Remi repository is enabled on your system, list the available PHP version by executing the below-mentioned command:

$ sudo dnf module list php

Step 2: Enable PHP module

As we discussed earlier, the PHP module is default set to PHP 7.2. If you want to install the latest PHP release then, enable the appropriate version on your CentOS 8 system.

To enable the PHP 7.3, you can use the below-mentioned commands:

$ sudo dnf module reset php
$ sudo dnf module enable php:remi-7.3

For example, we want to install the latest PHP 7.4 release on CentOS 8 system. In this case, by running the following command, you can enable it on your system:

$ sudo dnf module reset php

$ sudo dnf module enable php:remi-7.4

Now, the PHP 7.4 module is enabled on your system as follows:

Step 3: Installing PHP on CentOS 8

It’s time to start the installation of PHP and common PHP 7.4 module as follows:

$ sudo yum install php-fpm php-common php-cli

The above command will not install apache dependencies. During installing the above modules, the FPM will be installed as a dependency. This will be used as a FastCGI server. Now, enable and start the FPM service by running the following command:

$ sudo systemctl enable –now php-fpm

$ sudo systemctl start php-fpm.service

Now, check the installed Php version by using the following command:

$ php --version

Conclusion

We have installed PHP on CentOS 8 in this article. Moreover, we explored how to change the default PHP version to the latest available version. After installing the PHP on your system, you can configure it with an Apache webserver or Nginx. Thanks!

Similar Posts