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. 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.
How to Install PHP on CentOS 8 ?
To install the PHP on CentOS 8 system, you require performing the following steps.
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
2. Enable PHP module
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.
3. Install PHP on CentOS 8
To start the installation of PHP and common PHP 7.4 module, run the below command:
$ sudo yum install php-fpm php-common php-cli
This 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 commands:
$ 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
[Need assistance in fixing PHP configurations on your Linux system ? We can help you. ]
This article covers how to install PHP on CentOS 8. You will also see 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.
PHP (PHP: Hypertext Preprocessor) is a server-side scripting language designed for web development but also used as a general-purpose programming language. PHP code is interpreted by a web server with a PHP processor module, which generates the resulting web page: PHP commands can be embedded directly into an HTML source document rather than calling an external file to process data.