How To Install PHP 5.4 Using Yum On CentOS 5/6/7?

Introduction About PHP?

PHP is one the most used server-side programming language is the world. It is still most widespread and most popular server-side scripting language. Also, PHP is an open source web scripting language that is widely used to build dynamic web pages and web applications. Though it is not the best but, its modules and libraries made it so popular and really cut your programming time. It also communicates with databases like MySql and supported by web servers like Apache. Well, you will happy to know that YAHOO and FACEBOOK started with PHP and successful.

Scenario: My Server IP is

Note: If you are a SUDO user then prefix every command with sudo, like #sudo ifconfig

Step 1: Enable Remi Repository

The most of the updated package is available under Remi repository. Install it in your system using following commands.

Step 2: Install PHP With REMI

To install PHP type in the following command into your terminal

Here php-mysql is a module that PHP can communicate with the databases. After the completion of this command, PHP will be installed.

Step 3: Look For PHP Modules

As PHP is installed but your application may require a various module to process. Well, thanks to its developers that there is a wide variety of useful libraries and modules which you can add to your server. If you want to look for available PHP modules type in the following command:

Your server will communicate with the repository and it will list all the available modules. And the output windows will look like this:

Step 4: Install A module

If you have to install a specific module then you may type the following command

Well, Congratulations! You with the completion of this part 3 you have successfully setup a LAMP environment.

Step 5: Start PHP

Now to check your installation you need to restart or reload your Apache server and MySql server to get PHP start (PHP will run automatically once Apache starts):

Step 6: The Final And Check Your Installation

We have successfully setup LAMP environment and we can test this by creating a simple PHP file and calling a PHP function known as phpinfo(). So let’s create that file

Add in the following line:

Now Open your Web Browser and hit

NOTE: Replace my IP address with your IP like http://YourIPAddress/info.php

If you can see a page like below then your LAMP is successfully setup and PHP is installed and working.

How To Install PHP 5.4 Using Yum On CentOS 5/6/7?

NOTE: Don’t forget to delete info.php page on a production server because it’s a security threat, as all your server details are open to the public.

Love to write technical stuff with personal experience as I am working as a Sr. Linux Admin. and every day is a learning day and Trust me being tech geek is really cool.

Leave a Reply