How to Install PHP 8 on CentOS 8 / RHEL 8

Wired Gorilla
3 min readDec 13, 2020

--

Hello Geeks, recently PHP 8 has been released officially. It is a new major version and comes with lot of new improvements and features. In this article, we will demonstrate on how to install latest version of PHP 8 on CentOS 8 and RHEL 8 system.

Prerequisites for PHP 8

  • Minimal CentOS 8 / RHEL 8
  • User with sudo rights
  • Internet Connection

Let’s deep dive into the php 8 installation steps,

Note — These steps are also applicable for CentOS 8 stream operating system.

Step 1) Apply Updates

Login to your CentOS 8 / RHEL 8 system and apply the updates using beneath commands,

$ sudo dnf update $ sudo dnf upgrade

Once all the updates are applied successfully then take a reboot of your system once.

$ sudo reboot

Step 2) Enable EPEL & Remi Repository

PHP 8 is not available in the default CentOS 8 and RHEL 8 package repositories. So, we have to enable EPEL and remi repositories. Run following commands to enable them,

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

Run below command to list the available versions of PHP,

$ sudo dnf module list php

Output of above command would be:

PHP8-modules-list-centos8

Step 4) Install PHP 8 using Remi Module

Run the following commands to reset PHP module and install PHP 8 from remi-8.0 module.

$ sudo dnf module reset php $ sudo dnf module install -y php:remi-8.0
Install-php8-remi-repository-centos8-rhel8

Once the PHP packages are installed successfully then execute below command to verify PHP version,

[linuxtechi@centos-8 ~]$ php -v PHP 8.0.0 (cli) (built: Nov 24 2020 17:04:03) (NTS gcc x86_64 ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies [linuxtechi@centos-8 ~]$

Great, above output confirms that PHP 8 has been installed. This PHP is for HTTPD web server.

To Install PHP 8 for NGINX web server, we have to install php 8 fpm package.

$ sudo dnf install -y php-fpm

Once php-fpm package is installed then start and enable its services by executing following command,

$ sudo systemctl enable php-fpm --now

To verify the status of php-fpm service, run

$ systemctl status php-fpm
Verify-Status-php-fpm-service

PHP 8 extensions can also be installed via dnf command, some of the php 8 extensions installation example is listed below:

$ sudo dnf install -y php-{mysqlnd,xml,xmlrpc,curl,gd,imagick,mbstring,opcache,soap,zip}

Step 5) Configure PHP 8 for HTTPD & NGINX

To configure the PHP 8 for web servers, edit its configuration file and tweak the parameters that suits to your setup.

$ 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 & close the file and then restart web server’s service to make above changes into the effect.

For NGINX Web server, php-fpm is configured via its configuration file ‘/etc/php-fpm.d/www.conf’. you can tweak user and group information that suits to your setup. After making the changes, restart the php-fpm service.

That’s all from this article. I hope these helps you to install latest version of PHP 8 on your CentOS 8 / RHEL 8 system.

Also Read : 8 Stat Command Examples in Linux

The post How to Install PHP 8 on CentOS 8 / RHEL 8 first appeared on LinuxTechi.

--

--

No responses yet