Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install PHP 8 on CentOS/RHEL 8/7 - DesignLinux

Dec 10 2020
designlinux 0 Comments

PHP is a popular open-source server-side scripting language that is integral in developing dynamic webpages. PHP 8.0 is finally out and was released on November 26th, 2020. It promises lots of improvements and optimizations which are set to streamline how developers write and interact with PHP code.

In this guide, you will learn how to install PHP 8.0 on CentOS 8/7 and RHEL 8/7.

Step 1: Enable EPEL and Remi Repository on CentOS/RHEL

Right off the bat, you need to enable the EPEL repository on your system. EPEL, short for Extra Packages for Enterprise Linux, is an effort from the Fedora team that provides a set of additional packages that are not present by default on RHEL & CentOS.

$ sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm  [On CentOS/RHEL 8]
$ sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm  [On CentOS/RHEL 7]

Remi repository is a third-party repository that provides a wide range of PHP versions for RedHat Enterprise Linux. To install the Remi repository, run the command:

$ sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm  [On CentOS/RHEL 8]
$ sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm  [On CentOS/RHEL 7]

Step 2: Install PHP 8 on CentOS/RHEL

Once the installation is complete, proceed and list the available php module streams as shown:

$ sudo dnf module list PHP

Right at the bottom, be sure to notice the remi-8.0 php module.

List PHP 8 Modules
List PHP 8 Modules

We need to enable this module before installing PHP 8.0. To enable php:remi-8.0, execute:

$ sudo dnf module enable php:remi-8.0 -y
Enable PHP Remi Module
Enable PHP Remi Module

Once enabled, install PHP 8.0 for Apache or Nginx web server as shown:

Install PHP 8.0 for Apache

To install PHP 8 on the installed Apache web server, run:

$ sudo dnf install php php-cli php-common
Install PHP 8 for Apache
Install PHP 8 for Apache

Install PHP 8.0 for Nginx

If you are using Nginx in your development stack, consider installing php-fpm as shown.

$ sudo dnf install php php-cli php-common php-fpm

Step 3: Verify PHP 8.0 on CentOS/RHEL

There are two ways that you can use to verify the PHP version. On command-line, issue the command.

$ php -v
Verify PHP 8 from Command-line
Verify PHP 8 from Command-line

Additionally, you can create a sample php file in the /var/www/html folder as shown:

$ sudo vim /var/www/html/info.php

Then add the following PHP code which will populate the version of PHP alongside installed modules.

<?php

phpinfo();

?>

Save and exit. Be sure to restart the Apache or Nginx web server as shown.

$ sudo systemctl restart httpd
$ sudo systemctl restart nginx

Next, head over to your browser and go to the address shown:

http://server-ip/info.php

The webpage displays a wealth of information regarding the version of PHP installed such as build date, build system, Architecture, and a host of PHP extensions.

Check PHP 8 Info
Check PHP 8 Info

Step 3: Install PHP 8.0 Extensions in CentOS/RHEL

PHP extensions are libraries that provide added functionality to PHP. To install a php extension, use the syntax:

$ sudo dnf install php-{extension-name}

For example, to enable PHP to seamlessly work with MySQL, you can install the MySQL extension as shown.

$ sudo dnf install php-mysqlnd

Finally, you can verify the installed extensions using the command:

$ php -m

To verify if a specific extension is installed, execute:

$ php -m | grep extension-name

For example:

$ php -m | grep mysqlnd
Verify PHP Extension
Verify PHP Extension

In the end, we hope that you can now comfortably install PHP 8.0 alongside various php extensions on CentOS/RHEL 8/7.

Related

Tags: CentOS Tips, PHP Tips, RHEL Tips

Chattr Command in Linux (File Attributes)

Prev Post

How to Migrate CentOS 8 Installation to CentOS Stream

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 1
  • 629
  • 1,055,401

DesignLinux.com © All rights reserved

Go to mobile version