9.2 C
Amsterdam
Wednesday, January 20, 2021

How to install PHP 8 on CentOS 8?

Must read

Please Donate

angeloma
angeloma
Senior Writer and partner

Hello, friends. This post will help you install PHP 8 on CentOS 8. The procedure is quite simple.

PHP 8 has seen the light and comes loaded with many interesting new features and is a step ahead of the most popular web programming language. So many developers and sysadmin may be eager and ready to install it on their CentOS 8

Install PHP 8 on CentOS

For this tutorial, we’ll use Apache as the server but you can also install Nginx. In any case, the important thing about this post is the installation of PHP 8.

Open a terminal and with the help of sudo, update CentOS

sudo dnf update

Then, install the Apache webserver

sudo dnf install httpd

Enables Apache service to boot up and initialize the system

sudo systemctl enable httpd
sudo systemctl start httpd

Now check its status

sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2020-11-26 12:13:02 EST; 2s ago
Docs: man:httpd.service(8)
Main PID: 15871 (httpd)
Status: "Started, listening on: port 80"
Tasks: 213 (limit: 2860)
Memory: 17.2M
CGroup: /system.slice/httpd.service
├─15871 /usr/sbin/httpd -DFOREGROUND
├─15874 /usr/sbin/httpd -DFOREGROUND
├─15875 /usr/sbin/httpd -DFOREGROUND
├─15876 /usr/sbin/httpd -DFOREGROUND
└─15877 /usr/sbin/httpd -DFOREGROUND
Nov 26 12:13:00 osradar systemd[1]: Starting The Apache HTTP Server…
Nov 26 12:13:02 osradar httpd[15871]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.1.18. Set the 'ServerName' di>
Nov 26 12:13:02 osradar systemd[1]: Started The Apache HTTP Server.
Nov 26 12:13:05 osradar httpd[15871]: Server configured, listening on: port 80

So, Apache is running smoothly. Now you have to open the corresponding ports in the firewall:

sudo firewall-cmd --add-service=http --permanent
success
sudo firewall-cmd --add-service=https --permanent
success
sudo firewall-cmd --reload
success

This way, Apache is ready to receive PHP 8.

Now it’s time to install PHP 8 thanks to the REMI repository. So add it,

sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

and then update the distribution

sudo dnf update

CentOS 8 incorporated the modules to better manage the packages and their versions. So, disable the default module of PHP 7.2.

sudo dnf module disable php

And enable the REMI repository

sudo dnf module enable php:remi-8.0

Then install PHP 8 and some modules

sudo dnf install php php-common php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-gd php-mbstring php-xml
1.- Install PHP 8 on CentOS 8
1.- Install PHP 8 on CentOS 8

To test the installation, make a file with the phpinfo method.

sudo nano /var/www/html/test.php
<?php
phpinfo();
?>

Save the changes and now open it from a web browser

2.- PHP 8 working
2.- PHP 8 working

So, PHP 8 is correctly installed on CentOS 8.

Conclusion

PHP 8 is another step forward in the development and evolution of the language. As CentOS 8 is a server operating system it is not surprising that many people want to have this new version so that new applications can take advantage of it.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

-

Latest article

x