Select Page

Installing LAMP with MySQL or MariaDB on Ubuntu 18.04

Installing LAMP with MySQL or MariaDB on Ubuntu 18.04

Introduction

The LAMP stack is an collection of open source software components used to create websites and applications. The acronym LAMP comes from the four components:

  • Linux: The operating system which makes up our first component or layer which the rest of our components run on top of.  Whilst you can run the other components under Windows, OSX etc., doing so means you loose the L and therefore it’s no longer LAMP.
  • Apache: The second layer is the web server. Web servers connect a user’s browser (such as Firefox, Chrome, Safari), to websites and other services running on the server. The Apache server is extremely popular and runs 60% to 70% of all websites on the internet.
  • MySQL: This third layer provides database functionality for websites and applications.  MySQL can run on the same server as the rest of the LAMP stack, or run on separate hardware for busy websites or where high availability is required.
  • PHP: Our fourth and final layer is the scripting / programming language.  You can imagine PHP as being the glue that binds all the layers together. The majority of web sites use PHP.

Although not specifically designed to work together, these four components have become the de facto web development platform and are to be found in nearly all Linux distros.

In years gone by, the M in LAMP stood only for MySQL, but since Oracle purchased MySQL way back in 2009 a new fork of the code was created named MariaDB.

MariaDB is a drop in replacement for MySQL, so system admins and developers can choose which to install, and both are referred to as LAMP.

Preparations

One assumes Linux is already installed and up and running.  If this isn’t the case then take a look at the post Installing Ubuntu 18.04LTS before you proceed.

Being prepared is always a good start so before we begin let’s ensure our Ubuntu is up to date.

>sudo apt update && sudo apt upgrade

Installing The Database

As previously mentioned, there are four components to the LAMP stack.  If you’ve got this far then you should have Linux installed by now.

To Install the database component you need to decide between MySQL and MariaDB.

If you’ve decided on MySQL then follow the instructions in the post Installing MySQL on Ubuntu 18.04LTS then come back here.

If you’ve decided on MariaDB then follow the instructions in the post Installing MariaDB on Ubuntu 18.04LTS then come back here.

Installing The Software

With the databases installed we need to install Apache and PHP.  We can do this in one step with the command below.

>sudo apt install  php-mysql apache2 php-intl libapache2-mod-php php-curl php-xmlrpc php-gd

Whether you’re using MariaDB or MySQL the php-myql installer above is still valid.

image

You will be shown all the associated packages that will be installed as above.  It might seem like a lot but don’t worry – we’ll be needing them so confirm installation by typing [Y] and pressing the [ENTER] key.

Depending on your server and internet connection speed, this can take a while so sit back and relax.

When complete you’ll be returned to the command prompt.

Now whilst that is the end of the install, as you might imagine there is some configuration work to do.

A lot of what comes next depends on what you want do do.

If you just want to create a simple website then take a look at this next post:

Basic Apache Configuration on Ubuntu 18.04LTS

or if you want to install WordPress then take a look at this aptly named post:

Installing WordPress on Ubuntu 18.04LTS

Leave a reply