Install LAMP Server on Ubuntu OS

Profile picture for user devraj
Submitted by devraj on

A LAMP stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps.

The term LAMP is an acronym which stands for Linux, Apache, MySQL and PHP.

Below are the steps to follow on Terminal:

Step 1: Install Apache

sudo apt-get install apache2

Step 2: Install MySQL

sudo apt-get install mysql-server

Step 3: Install PHP

sudo apt-get install php5 libapache2-mod-php5

Step 4: Restart Server

sudo /etc/init.d/apache2 restart

Step 5: Verify Apache Installed

Type http://localhost/ in your browser. You will see apache ubuntu default screen.

Step 6: Check MySQL Installed

sudo mysql

Type above command you will see below Message. You can type exit to exit from MySQL.

$ sudo mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit

Step 7: Check PHP is installed 

php -r 'echo "\nPHP installation is done.\n\n";'

Type above command on terminal, you will get above Message "PHP installation is done" on terminal.

That's it, your LAMP installation is done and verified.