Installation of Linux, Apache, MySQL, PHP (LAMP) on CentOS 6

About LAMP-Stack

 LAMP represents Linux, Apache, MySQL and PHP.  It  is an open source software group which is used for managing web servers.


The user must have root privileges on the server to install and the steps are given below:

Step One – Installation of Apache & MySQL

Almost half of the web servers running across the globe are running Apache.  It is an open source and free software.

You can install it by simply typing command in your terminal:

sudo yum install httpd

After installation has completed, root password MySQL can be set:
sudo / usr / bin / mysql_secure_installation

You can  type in your existing root password.  If you are using it for the first time just  press ‘Enter’ and leave it blank.

Type in the current password for the root directory if you have it or press ‘Enter’ to leave it.

Select “Y” to to set the root password and follow the instruction provided.


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
Remove anonymous users? [Y / n] y                                            
 ... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y / n] y
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y / n] y
 - Dropping test database ...
 ... Success!
 - Removing privileges on test database ...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y / n] y
 ... Success!

Cleaning up ...

All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Step Two – Installation of PHP

PHP is widely used to create dynamic web pages which is also an open source scripting programming language.

To install just open  terminal and follow these steps

sudo yum install php php-mysql

PHP will be deployed as soon as you answer yes to the invitation PHP.

PHP modules

Additionally, PHP has a number of useful modules and libraries that one can add to his server. The available libraries can be browsed by entering:

yum search php-

A number of 
possible modules are then displayed by the terminal. The list is as follows:

php-bcmath.x86_64: A module for PHP applications for using the bcmath library
php-cli.x86_64: Command-line interface for PHP
php-common.x86_64: Common files for PHP
php-dba.x86_64: A database abstraction layer module for PHP applications
php-devel.x86_64: Files needed for building PHP extensions
php-embedded.x86_64: PHP library for embedding in applications
php-enchant.x86_64: Human Language and Character Encoding Support
php-gd.x86_64: A module for PHP applications for using the gd graphics library
php-imap.x86_64: A module for PHP applications that use IMAP

if you need more  information about each module’s execution, just type it like below:

yum info name of the module

Type in the command below once as you opt to deploy the module:

sudo yum install name of the module

If you want Apache and mysql service to run whenever your system boots then you can type:

sudo chkconfig httpd on sudo chkconfig mysqld on

Step Three – RESULTS: Mind your PHP

If LAMP has been deployed on a virtual server you can get a ‘quick’ information page about PHP.

For this, you need to make a new file:

sudo nano / var / www / html / info.php

add the line:

<? Php phpinfo (); ?>

Next press “Save” and “Exit”. Now restart Apache:

sudo service httpd restart

You can check by visiting your page with PHP details (ensure replacing the demo IP-address with your own IP-address):

KB Admin has written 46 articles