Home » Linux » How To » Install LAMP Stack on CentOS, RHEL, Fedora

Install LAMP Stack on CentOS, RHEL, Fedora

LAMP is nothing but a bundle of softwares which make environment for running website. Full form of LAMP is ‘L’inux ‘A’pache ‘M’ysql ‘P’HP.

So, LAMP mainly used to run such website which is written in PHP & MySql.

Now a days PHP is very popular language, many ready to use framework written in PHP & MySql as database support.
WordPress, Joomla, Drupal is very popular CMS, used for blog, commercial website, e-commerce. Many formal e-commerce framework designed in PHP – MySql , like OpenCart, WHMCS many more.

Ok! Ltes Start ! Learn How To Install LAMP Stack on CentOS, RHEL, Fedora

I have setup this tutorial in CentOS 6 box.

System Status :
IP :
OS : CentOS 6.4 x64

Install LAMP Stack

 [root@unixhops ~]# yum update
 [root@unixhops ~]# yum install httpd php mysql-server

During installation process it may popup for mysql root password, enter mysql root password & continue. this will complete basic installation of LAMP.

Now complete post installation configuration

Adjust MySql

[root@unixhops ~]#  /usr/bin/mysql_secure_installation

The prompt will ask you for your current root password.
Since you just installed MySQL, you most likely won’t have one, so leave it blank by pressing enter.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Then the prompt will ask you if you want to set a root password. Go ahead and choose Y and follow the instructions.

CentOS automates the process of setting up MySQL, asking you a series of yes or no questions.

It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.

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
production environment.
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!

Install essential PHP module

PHP have variety of useful libraries and modules that you can add onto your server. You can see the libraries that are available by typing:

 yum search php-

Terminal then will display the list of possible modules. The beginning looks like this:

 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
 php-mysql.x86_64 : Dynamic shared object (DSO) that adds MySQL support to PHP

In this tutorial I will install some basic module

[root@unixhops ~]# yum install php-mysql php-gd php-common php-cli

Now we are ready to fire up.

[root@unixhops ~]# service httpd start
[root@unixhops ~]# service mysqld start
[root@unixhops ~]# chkconfig httpd on
[root@unixhops ~]# chkconfig mysqld on

Default document root directory /var/www/html

lets put a php file into it , t fetch php information

 [root@unixhops ~]# nano /var/www/html/phpinfo.php

<?php phpinfo(); ?>

vist your machine IP from browser

the page should look like this


Check Also

Password less SSH authentication

Password less SSH authentication is one of the best security practices to avoid any password …

Leave a Reply

Your email address will not be published. Required fields are marked *