How to Install PHP on CentOS 7

We Have Already talk about How to Configure CentOS Linux As a Web Server Using Apache HTTPD Server. Now we have come to the next step, That is to Learn How to Install PHP on CentOS 7. This Essential if you are planning to run your own web server since Most Popular Content Management Systems have been written using PHP Language.

PHP  Has been the most Popular Scripting Language Because it Works with several commercial and non commercial Databases Management Systems and Allows to Create Dynamic Web Pages Easily.

Before We Begin

Unlike Static HTML Web Pages PHP needs to run on a Web Server Like Apache. So Before you Install PHP It is Better to Configure Your CentOS machine as a Web Server. Click Here to Read This Tutorial How to Configure Apache Web Server On CentOS7.

Install PHP With Yum Command

PHP Language Available in Default CentOS Repository So can be easily installed with yum command.

yum install php

Location of the Main Configuration File is /etc/php.ini

Also During the Installation Process Following Packages Will Be Installed Automatically if not already exist.

  • apr – Apache Portable Runtime library
  • apr-util – Apache Portable Runtime Utility library
  • httpd – Apache Web Server
  • httpd-tools
  • libzip – libzip is a C library for reading, creating, and modifying zip archives.
  • mailcap
  • php-cli – command-line interface for executing PHP scripts
  • php-common

You Can Verify Your PHP Installation By Creating Sample index file with phpinfo() function.