How To Install php on CentOS 7

In this tutorial we learn how to install php on CentOS 7. php is PHP scripting language for creating dynamic web sites

Introduction

In this tutorial we learn how to install php on CentOS 7.

What is php

PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers to write dynamically generated web pages. PHP also offers built-in database integration for several commercial and non-commercial database management systems, so writing a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding is probably as a replacement for CGI scripts. The php package contains the module (often referred to as mod_php) which adds support for the PHP language to Apache HTTP Server.

We can use yum or dnf to install php on CentOS 7. In this tutorial we discuss both methods but you only need to choose one of method to install php.

Install php on CentOS 7 Using yum

Update yum database with yum using the following command.

sudo yum makecache

After updating yum database, We can install php using yum by running the following command:

sudo yum -y install php

Install php on CentOS 7 Using dnf

If you don’t have dnf installed you can install DNF on CentOS 7 first. Update yum database with dnf using the following command.

sudo dnf makecache

After updating yum database, We can install php using dnf by running the following command:

sudo dnf -y install php

How To Uninstall php on CentOS 7

To uninstall only the php package we can use the following command:

sudo dnf remove php

References

Summary

In this tutorial we learn how to install php on CentOS 7 using yum and dnf.