How to Install PHP 8 on CentOS 8

Install PHP 8 on CentOS 8

In this article, we will have explained the necessary steps to installing and configure PHP 8 on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

PHP is one of the most used server-side programming languages. Many popular CMS and frameworks such as WordPress, Laravel, and many more are built in PHP. The latest PHP 8 version is officially released on November 26th, 2020. It comes with a number of new features and a few incompatibilities that you should be aware of before upgrading from the previous version.


  • Operating System with CentOS 8
  • Server IPv4 Address with Superuser Privileges (Root Access)
  • Gnome Terminal for Linux Desktop
  • PuTTy SSH client for Windows or macOS
  • Powershell for Windows 10/11
  • Familiar with DNF Commands

Install PHP 8 on CentOS 8

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo dnf install epel-release
sudo dnf update

Step 2. Install PHP on the CentOS system.

PHP 8.0 is not available in the default CentOS repositories, If you want to install PHP 8 enable the Remi and EPEL repository by running the following command as root or user with sudo privileges :

sudo dnf install
sudo dnf install
sudo dnf install yum-utils

Once done, reset the module and enable PHP 8:

sudo dnf module reset php
sudo dnf module install php:remi-8.0

Then, install PHP and some of the most common PHP modules:

sudo dnf install php
sudo dnf install php-{cli,fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json}

To install any additional PHP package use command syntax:

sudo dnf install php-extension_name

Check the PHP version:

$ php --version
PHP 8.0.0 (cli) (built: Dec 1 2020 16:32:11) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies

Step 3. Configure PHP 8.

Now we configure PHP for Web Applications by changing some values in php.ini the file:

sudo nano /etc/php.ini

Update the following values for better performance:

upload_max_filesize = 32M 
post_max_size = 32M 
memory_limit = 512M 
max_execution_time = 600 
max_input_vars = 3000 
max_input_time = 1000

That’s all you need to do to install PHP on CentOS 8. I hope you find this quick tip helpful. For further reading on PHP 8, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.