How to install LAMP in ubuntu 18.04 ?

   | Posted On : 2019 - 08 - 03   |   2 years ago   |    linux, open-source

Install LAMP In Ubuntu

LAMP is an archetypal model of web service stacks, named as an acronym of the names of its original four open-source components: which are Linux, Apache HTTP server, My SQL, PHP (LAMP).

In this article, I will explain how to install LAMP stack in Ubuntu 18.04. Without further delay let’s get started before that if you guys are enjoying my articles please make sure you share it with your friends 🙂 so Let’s Start.

1. Install Apache

In LAMP, Our first step is to install Apache. To install Apache you must install the Metapackage apache2. Which can be done by searching in its software center or by running the following command.

sudo apt-get install apache2

2. Install My SQL

My SQL can be used for managing databases (Creating, Dropping, Renaming etc). To install My SQL you must install the Metapackage mysql-server. Which can be done by searching in its software center/over the internet or by running the following command.

sudo apt-get install mysql-server

3. Install PHP

PHP (Hypertext Preprocessor) is a popular general-purpose scripting language that is especially suited to web development. To install PHP it requires few packages to work as you expect, so i recommend following command.

sudo apt install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php

4. Restart Server

Your server should restart Apache automatically after the installation of both MySQL and PHP. If it doesn’t, execute this command to run it manually.

sudo service apache2 restart

5. Check Apache (If It’s Running Or Not)


Open a web browser and navigate to http://localhost/. If you see the apache default web page, it means your installation is working fine.

fig. Ubuntu Default Apache Page On Localhost

6. Check PHP (If It’s Running)

Now, Let’s create a PHP file to check if your PHP is working or not. Follow the steps to create a PHP file from command line to your /var/www/html (localhost server directory) folder.

cd /var/www/html && vi /var/www/html/info.php

Now, Press Insert button on your keyboard and type the following content under your info.php

<?php phpinfo(); ?>

Note:- :wq! to save and exit from vi editor.

Now, Run http://localhost/info.php on your web browser (Firefox, chrome, safari etc.) if you’re seeing PHP information then PHP is installed on your computer successfully.

That’s it! In this article, I have explained How to install LAMP on Ubuntu 18.04 ? Thank You For Reading This Article, Let me know your comments what’s your thought in this article.

What is your reaction to this post ?

Like Love Haha Wow Sad Angry

Give Comments