• Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install PHP 8 on CentOS/RHEL 8

Written by Rahul, Updated on February 15, 2021

PHP 8.0 is a major update released by the PHP team on Nov 26, 2020. It contains a large number of new features and optimizations over previous versions. To read more about read the PHP 8 change log.

REMI and EPEL are the most popular repositories contains latest RPM packages for installation. It also contains the PHP 8 RPM packages to be install on CentOS/RHEL 8 systems.

This article will describe you to how to install PHP 8 on CentOS 8 or RHEL 8 Linux system.

Before we Begin

Login to the CentOS 8 system with sudo privileged account.

Optionally, you can upgrade the current packages on your system by executing command.

dnf upgrade  

Step 1 – Enable PHP Repository

The CentOS/RHEL default repositories don’t contain latest PHP 8 packages. In order to install PHP 8 on CentOS 8 system, enable EPEL and REMI yum repositories on your system.

Open a terminal and execute below commands to configure REMI and EPEL repositories:

sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm  

Once you installed both the above packages, Use dnf command line tool to active php:remi-8.0 repository, which contains PHP 8 packages.

sudo dnf module enable php:remi-8.0 -y  

Verify the active repository for the php packages on your system.

sudo dnf module list php  

Make sure the remi-8.0 steam is active for the php packages. It will have [e] just after the repository name. See the below screenshot:

Enable PHP 8 Repository on CentOS/RHEL 8

Step 2 – Installing PHP 8 on CentOS

Your system is ready for the PHP 8 installation. Run the following command from terminal.

sudo dnf install php php-cli php-common  

Press ‘y’ for any confirmation prompted during installation.

Once the installation succeeded, execute the below command to view installed PHP version on your syste.

php -v  

Install PHP 8 on CentOS 8

At this stage, you have successfully install PHP 8 on CentOS 8 and RHEL 8 systems.

Step 3 – Install Apache with PHP 8 on CentOS

This is the optional step for you, if you just need PHP CLI to running php scripts.

But in most cases, we use Apache for deploying PHP based web application. Just execute the following command to Apache web server on your system.

sudo dnf install httpd -y  

Now, verity that Apache is read to serve php files over the web. Lets create php info file on your CentOS server. The default virtulhost uses /var/www/html as document root. So create a file under this directory:

echo "<?php phpinfo(); ?>" >  /var/www/html/info.php  

Next access info.php file using the server ip address as below:

Installing PHP 8 on CentOS/RHEL 8

Step 4 – Installing PHP Extension

Generally the web application depends on multiple PHP extension. A PHP extension is a specially formed library for the specific tasks.

View the available PHP extensions, type:

sudo dnf search php-* 

Now, install all the required PHP extension for your application.

sudo dnf install php-gd php-mbstring php-mysqlnd 

Use -m option to view currently enabled php extensions.

php -m 
php -m | grep extension-name 

Conclusion

This tutorial helped you to install PHP 8.0 including the required extension on CentOS/RHEL 8 Linux system.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Debian 10
  • Download Ubuntu 20.04 LTS – DVD ISO Images
  • Linux Run Commands As Another User
  • How to Check PHP Version (Apache/Nginx/CLI)
  • How To Install and Configure GitLab on Ubuntu 20.04
  • How to Install PyCharm on Ubuntu 20.04
  • How to Check Ubuntu Version with Command or Script
  • How to Set all directories to 755 And all files to 644
© 2013-2021 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy