• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install PHP 8 on CentOS 8

Written by Admin, Updated On January 23, 2021
centos, php

PHP is a most popular server scripting language used for creating dynamic and interactive Web pages. Recently PHP 8 has been released officially. This tutorial explains how to install PHP 8 on CentOS 8 system.

PHP 8.0 is the latest major release and includes performance improvements, and lots of new features such as named arguments, JIT compiler, union types, match expression, and more. We’ll use REMI repository to install PHP 8.

Prerequisites#

You must logged in with root or user with sudo privileges.

Install PHP 8 on CentOS 8#

Perform the following steps to install PHP 8 on CentOS system.

Step 1 – Update System#

Use the following command to update your CentOS 8 / RHEL 8 system.

sudo dnf update
sudo dnf upgrade

Once the updates applied, you can reboot your system using below command. It’s an optional to reboot.

sudo reboot

Step 2 – Enable EPEL & Remi Repository#

By default, CentOS 8 package repositories doesn’t includes PHP 8. So, we have to enable EPEL and remi repositories. Run following commands to enable:

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

Step 3 – Install PHP 8#

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

Step 4 – Verify Installation#

You can verify the installation using --version command:

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

By default, Nginx doesn’t have a built-in support for processing PHP files. So we need to use PHP FPM service to handle the PHP files.

sudo dnf install -y php-fpm

You must start and enable its services once the php-fpm package is installed. Run following command:

sudo systemctl enable php-fpm --now

To verify the status of php-fpm service, run:

systemctl status php-fpm

Installing PHP Extensions#

You can install PHP extensions as per requirements. You can easily install extensions using dnf package manager in following form:

sudo dnf install -y php-[extension]

For example, to install curl and mbstring extensions, you would run the following command:

sudo dnf install -y php-{curl,mbstring}

You must restart the Apache or PHP FPM service after installing extensions.

Conclusion#

I hope you successfully learned how to install PHP 8 on CentOS 8 / RHEL 8 system.

If you have any questions or feedback, please leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install LibreOffice 7.0 on Debian 10
Next Article   How to Install Microsoft Edge Browser on Ubuntu 20.04

Related Posts

  • How to Install Apache, MySQL, PHP (LAMP) on Ubuntu 22.04

    How to Install LAMP on Ubuntu 22.04

    March 20, 2023
  • How to Install LEMP Stack on Ubuntu 22.04

    How to Install LEMP Stack on Ubuntu 22.04

    March 18, 2023
  • How to Install PHP 8.2 on Debian 11

    How to Install PHP 8.2 on Debian 11 Linux

    February 24, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook