lamp stack

Installing LAMP Stack on Ubuntu 18.04 in Just 3 Steps

In this post, you’ll learn how to setup LAMP Stack on Ubuntu in just 3 easy to follow steps. I’m not making the post fatter, thinner and filled with a lot of theory. I’ll just go straight forward towards the installation process. But if you want to learn a little bit of theory behind the scene then you must read my blog Understanding Root Directory, Testing PHP Engine and Installing PHP Extensions on Ubuntu after this post. For now, let’s get started!

What Is LAMP Stack?

First of all, let’s define LAMP Stack for those of you who don’t know about it. LAMP Stacks means: “Storing/retrieving data in/from MySQL DBMS, on Linux Operating System, using PHP Server Side Scripting Language running on Apache Server”.

Please Note: some may say ‘P’ in LAMP is for Python and it might be, but we’ll focus on PHP.

Well, you’ve already completed the ‘L’ part of the LAMP as you are running Linux Kernel on your Ubuntu or Debian distro.

Installing LAMP Stack on Ubuntu 16.04 in Just 3 Steps

Step 1 – Installing Apache Server

  • Open your Terminal
  • Run the following commands one by one in your Terminal
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache2

The above given commands will:

  1. Update the list of available packages and their versions from the repository (Please do note: It just updates not downloads and installs new packages).
  2. Upgrade the packages on the bases of the list updated by update command (It actually installs new versions of packages).
  3. Installs PHP7.2 Engine on your machine.

The above-given commands will download Apache2 from the Ubuntu Application Repository or Debian Application Repository and will install it on your Ubuntu or Debian distro.

After installing Apache let’s check it. Type localhost in your browser and hit enter, you should see the following page if every thing is going right!

Apache server page on localhost

Step 2 – Installing MySQL

1. sudo apt-get install mysql-server-5.7
2. sudo apt-get install mysql-client-5.7
3. sudo apt-get install php7.2-mysql

The above give commands will install:

  1. MySQL Server 5.7.
  2. MySQL Client 5.7.
  3. MySQL Module Extension for PHP7.2 Engine.

Step 3 – Installing PHP Engine

  • Open Terminal
  • Type following command one by one
1. sudo apt-get install php7.2
2. sudo apt-get install libapache2-mod-php7.2

The above give commands will install:

  1. PHP7.2 Engine from the repository.
  2. PHP7.2 Module for Apache Server.

You’ve successfully installed PHP7.2, to check whether the installed PHP7.2 Engine is working properly, see Testing PHP Engine and if you want to make some configuration settings read Configuring php.ini. To know about and install PHP extension modules read my blog Learning about and Installing PHP Extensions on Ubuntu.

That’s all! you’ve completed the installation of LAMP Stack on your Ubuntu and/or Debian Machine. Quite easy? I hope your answer is Yes!

Leave a Reply

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