How to Install PHP 8 on CentOS 8

3 min readNov 30, 2020


How to Install PHP 8 on CentOS. This guide let you learn how install the latest PHP version 8 on your CentOS system or your CentOS server on any VPS or any Cloud or any Dedicated hosting and configure it with Httpd and Nginx.

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.

This installation is tested on Google Cloud Platform with a Compute Compute Engine VM Instance. So this set up is guaranteed to work on all Linux based servers.


  1. A CentOS server set up with sudo privileges.

Getting Started

Make sure your CentOS server is having the latest packages by running the following command.

sudo yum update
sudo yum upgrade

This will update the package index and update the installed packages to the latest version.

Install Remi Repository

As PHP 8.0 is not available in the default repositories you need to install the Remi repository and yum-utils and enable the epel-release.

sudo dnf -y install
sudo dnf -y install dnf-utils

Now you can see the available PHP version for installation using the following command.

sudo dnf module list php

You can see that PHP 8.0 will be available through the Remi repository.

Now you can reset the module and enable PHP 8.0

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

Once this is done you can install PHP 8.0

Install PHP 8 for HTTPD

Execute the following command to install PHP 8

sudo dnf install php

After the installation has completed, you can confirm the installation using the following command

php -vOutput

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
with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies

Install PHP 8.0 FPM for Nginx

For Nginx you need to install FPM, execute the following command to install PHP 8 FPM.

sudo yum install php-fpm

After the installation has completed, enable the service using the following command.

sudo systemctl enable php-fpm.service

Start PHP-FPM service with the below command.

sudo systemctl start php-fpm.service

Install PHP 8 Extensions

Installing PHP extensions are simple with the following syntax.

sudo dnf install php-extension_name

Now, install some commonly used php-extensions with the following command.

sudo dnf install php-{common,mysql,xml,xmlrpc,curl,gd,imagick,cli,dev,imap,mbstring,opcache,soap,zip,intl,bcmath} -y

Configure PHP 8.0

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

For PHP 8 the php.ini location will be in following directory.

sudo nano /etc/php.ini

Hit F6 for search inside the editor and update the following values for better performance.

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

Once you have modified your PHP settings you need to restart your Httpd or PHP-FPM for the changes to take effect.

Configure PHP 8 FPM Pools

PHP 8.0 FPM allows you to configure the user and group that the service will run under. You can modify these using the following commands.

sudo nano /etc/php-fpm.d/www.conf

Change the following lines by replacing the www-data with your username.

user = username 
group = username
listen.owner = username = username

Hit CTRL+X and Y to save the configuration and check if the configuration is correct and restart PHP.

Restart PHP 8 FPM

Once you have updated your PHP FPM settings you need to restart it to apply the changes.

sudo systemctl restart php-fpm.service

Now you are having PHP 8.0 Installed and configured in CentOS.

Become a Linux System Administrator and maintain virtual servers in a multi-user environment.


Now you have learned how to install PHP 8 on your CentOS server.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.




Discover the power of AI, data science, and cloud technology with our insightful blog. Stay ahead of the curve with the latest trends and strategies.