How To Install LAMP On CentOS 6

By August 23, 2014 Tutorials No Comments

What is LAMP?

LAMP is a combination of multiple open source software used to run a web server.  If you already do not know, LAMP is an acronym that stands for Linux, Apache, MySQL and PHP.  In this guide, we will be guiding you through the steps required to install Apache, MySQL and PHP since the linux part is taken care of by running CentOS as the Virtual Private Server’s OS.


Before starting to follow this guide, there are a few requirements to install the LAMP stack.

  • A Dedicated Server or VPS
  • At least 512MB RAM
  • Root Privileges

Once you acquire everything that is required, you may start following this guide.

Step One – Installing Apache (LAMP)

Apache is free and open source software which is currently used on many servers around the world.

To install Apache, open up your favourite SSH Client (PuTTY) and type in the following:

sudo yum install httpd

After it installs, start Apache to run on your server:

sudo service httpd start

That’s all there is to installing Apache.  If you want to make sure that it is up and running, using your browser, navigate to your site by using your server’s IP address (  You should be greeted with an Apache web page.

I forgot my IP address, what can I do?

If you’ve forgotten your server’s IP address or would like to find out what it is, there is a very easy solution.  In your SSH client, just enter the command:

ifconfig eth0 | grep inet | awk '{ print $2 }'

Step 2 – Installing MySQL (LAMP)

MySQL is an industry standard database management system used mainly for hosting.  To install MySQL, enter the commands:

sudo yum install mysql-server
sudo service mysqld start

During the installation process, you  must answer yes to the permission requests that MySQL asks, allowing MySQL to install.  After the installation of MySQL, you can set a root MySQL password with the command:

sudo /usr/bin/mysql_secure_installation

The prompt after entering the command will ask you for your current MySQL root password which by default should be nothing, so press enter.  The prompt will ask you whether or not you want to set a password.  To set a password, enter Y and input your new password as instructed.

Step 3 – Installing PHP (LAMP)

PHP is an open source web scripting language that is widely used to build dynamic webpages.  To install PHP, type in this command:

sudo yum install php php-mysql

Answer yes to the PHP prompt to allow it to be installed.

Step 4 – PHP Modules (LAMP)

PHP has a variety of modules and libraries that can be added to your server very easily.  Modules in PHP allow you to extend the usability of PHP.  You can check to see all the libraries available to install by running the command:

yum search php-

This will display a list of modules that are available to install.  If you decide to install a module, you can type in:

sudo yum install name of the module

Before finishing, we should make sure that the processes are all run at start-up, therefore enter the command:

sudo chkconfig httpd on
sudo chkconfig mysqld on

Congratulations!  You now have a LAMP stack, installed on your server!

Leave a Reply