LAMP is a group of open source which is deployed usually to host websites. In LAMP ‘L’ stands for Linux, the OS which provides the platform, ‘A’ stands for Apache, the webserver, ‘M’ stands for MySQL, the database server and ‘P’ stands for PHP which processes the dynamic content.

First, let’s install Apache webserver.

Open your terminal and type the following to install Apache via apt :

sudo apt-get install apache2

Once the web-server is installed, you can verify that if its able to serve the webpages by simply opening your server IP in a browser :


You would be able to see the default Apache2 ubuntu page which looks like :

apache2 ubuntu

We can now install the MySQL server from the terminal.

# sudo apt-get install mysql-server php5-mysql

We will need to install the package ‘php5-mysql ‘ which provides modules for MySQL database connections directly from PHP scripts

During the installation, you will need to confirm a password for the MySQL “root” user. This is an administrative account in MySQL that has increased privileges.


Once the installation is complete, type the following to create the database directory structure :

sudo mysql_install_db

Once this is done, we will have to follow some steps to make the MySQL configuration a safe one :

sudo mysql_secure_installation

You will have to enter the MySQL root password and then move ahead with some straightforward questions. You can decide whether to remove the sample db’s, and stuffs like disabling remote root logins etc. This is all with the MySQL installation.

After MySQL, we will move ahead with installing PHP in the server :

sudo apt-get install php5 libapache2-mod-php5

You can also decide if you wish to install the PHP modules along with this, modules like – php5-gd etc. You either install it now, or at a later time. An example would be like :

# sudo apt-get install php5-gd

With this, the installation of LAMP stack is over. We can now move ahead and test if the webserver is able to parse the pages without any issues.

Create a test php page  inside /var/www/html :

# vi /var/www/html/phpinfo.php


// Show all information, defaults to INFO_ALL


Now try to open the phpinfo page from your browser,