How to Install PHP 7.4 on CentOS 8 / RHEL 8

PHP (Hypertext Preprocessor) is the most popular server-side scripting language and used in developing static and dynamic web sites. In this article, we will demonstrate on how to install latest version of PHP 7.4 on CentOS 8 and RHEL 8.

Minimum System Requirements for PHP 7.4

  • Minimal CentOS 8 / RHEL 8 OS
  • Sudo or Root Privileges
  • Basic Package Repositories
  • Internet Connection

Let’s jump into installation steps,

Step:1) Enable EPEL and Remi Repository

In the default CentOS 8 and RHEL 8 package repositories, PHP 7.2 / 7.3 is available and to install latest version of PHP 7.4, we must configure EPEL and REMI repositories, so to enable the repositories, run the following commands:

[pkumar@linuxtechi ~]$ sudo dnf install epel-release -y
[pkumar@linuxtechi ~]$ sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y

Once the repositories are configured and enabled, run the following dnf command to view available PHP versions,

[pkumar@linuxtechi ~]$ dnf module list php

dnf-module-list-php-centos8

As we can see in above output, PHP 7.2 is the default package from CentOS-8 AppStream repository, so in the next step, we will enable latest PHP module stream (redmi-7.4) so that when we install install PHP using dnf then it will automatically pick packages from remi-7.4 module

Step:2) Enable latest PHP Module Stream (remi-7.4)

Execute the following dnf command to enable remi-7.4 PHP module,

[pkumar@linuxtechi ~]$ sudo dnf module enable php:remi-7.4

Enable-remi-7-4-mdoule

Step:3) Install and Verify PHP

Now run the following dnf command to install PHP 7.4,

[pkumar@linuxtechi ~]$ sudo dnf install php php-cli php-common

Install-php-7-4-CentOS8-RHEL8

As we can see that it is installing its dependencies like httpd and nginx, So once above packages are installed successfully, run below “php -v” command to verify installed php version,

[pkumar@linuxtechi ~]$ php -v

php-version-centos8

While installing PHP, php-fpm is also installed as its dependency, it will be treated as FastCGI Server, so use below command to start and enable FPM service,

[pkumar@linuxtechi ~]$ sudo systemctl start php-fpm
[pkumar@linuxtechi ~]$ sudo systemctl enable php-fpm

Step:4) Updating PHP Parameters

While using the php in different CMS (Content Management System) like WordPress, Drupal, Joomla and MediaWiki etc we might have to update default PHP parameters to improve the performance. These parameters can be alerted from its configuration file “/etc/php.ini”,

[pkumar@linuxtechi ~]$ sudo vi /etc/php.ini
…………
upload_max_filesize = 32M 
post_max_size = 48M 
memory_limit = 256M 
max_execution_time = 600 
max_input_vars = 3000 
max_input_time = 1000
………

Save and exit the file, To make the above changes into the effect restart your web server service (httpd or nginx )

[pkumar@linuxtechi ~]$ sudo systemctl restart httpd

That’s all from this article, I hope these steps help you install and configure PHP 7.4 on your CentOS 8 and RHEL 8 System. Your feedback and comments are most welcome.



from Linuxtechi https://ift.tt/3bBJfo5

Post a Comment

0 Comments