17 C
Texas
angeloma
Senior Writer and partner

How to install PHP 7.4 on CentOS 8?

A new version of PHP has come out and it’s time to install it on our servers. So in this post, you will learn how to install PHP 7.4 on CentOS 8. Having this version, you will be able to take better advantage of running websites.

As we know, PHP is a programming language widely used all over the world. In fact, most of the web sites and applications use it. Therefore, it is to be assumed that most servers need it.

By default, CentOS 8 includes version 7.2 in its official repositories. It’s actually a good version that will be supported for a while longer, but the language is advancing more and more every day. So, it is a good idea to install recent versions.

So, let us start.

Install PHP 7.4 on CentOS 8

Installing Apache web server on CentOS 8

- Advertisement -

Okay, the first step is to install a web server. It can be Apache or Nginx but in this case, I will use Apache. So I am going to install it.

Open a terminal session and run the following:

:~$ su
:~# dnf install httpd

After the installation is completed, the apache service must be started. We can also enable it to start together with the system:

:~# systemctl enable httpd
:~# systemctl start httpd

Then, you have to open the ports where the server works. Without this, we won’t have access to the documents on the server.

:~# firewall-cmd --add-port=80/tcp --permanent --zone=public
success
:~# firewall-cmd --add-port=443/tcp --permanent --zone=public
success
:~# firewall-cmd --reload
success

Now, we can install PHP 7.4 on CentOS 8.

PHP’s turn

To install PHP 7.4 we will use the REMI repository. It is quite stable and has a long history of use. But, first, we will have to enable the EPEL repository. We can do this with the following command:

:~# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
1.- Enabling the EPEL repository on CentOS 8
1.- Enabling the EPEL repository on CentOS 8

Next, we proceed to add the REMI repository for CentOS 8.

:~# dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
2.- Adding the REMI repository
2.- Adding the REMI repository

The REMI repository contains a large number of packages. By default, only those belonging to REMI-Safe are enabled. So, you have to enable REMI-7.4.

:~# dnf module enable php:remi-7.4
3.- Enabling the PHP 7.4 series
3.- Enabling the PHP 7.4 series

And now we can install PHP 7.4 and its modules without problems.

:~# dnf install php php-common php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-gd php-mbstring php-xml
4.- Install PHP 7.4 on CentOS 8
4.- Install PHP 7.4 on CentOS 8

Now we are going to prove that it all worked out. The best way to do this is to run PHP.

So, I am going to create a file called test.php in the apache root folder and add the phpinfo method to it.

:~# nano /var/www/html/test.php

Save the changes and close the editor.

Then, restart the apache service:

:~# systemctl restart httpd

Now open your web browser and go to http://your-server/test.php and you will see the following:

5.- PHP 7.4 on CentOS 8
5.- PHP 7.4 on CentOS 8

So, enjoy it.

Also, you can read all the features of this version in this link.

Finally, you can read these related posts:

How to install LAMP on CentOS 8?

How to install PHP 7.4 on OpenSUSE 15.1?

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article