What is the LAMP stack?

When you want to build web applications, especially in PHP, you often here the word LAMP. In this shot, you will learn what a LAMP stack is and how you can have one in your own computer.

LAMP stack in a nutshell

A stack is a collection of software or application programs that work together to make up a fully functional environment.

LAMP is an acronym for Linux, Apache, MySQL (MariaDB), and PHP (Python). They form the 4 layers that are needed to build a website, which are:

  • Operating system layer
  • Web server layer
  • Database layer
  • Scripting layer

LAMP originated from GNU/Linux world, but today we have something equivalent in almost every system.

Operating system

The operating system (OS) is the backbone for a LAMP stack. It is the foundation layer on top of which other layers run.

Historically, GNU/Linux was the OS used in this layer because it is free and open source, and also because of the flexibility and customization possibilities it offers.

Today, we have an equivalent in almost every operating system where the name changes accordingly. Therefore, we use “WAMP” on Windows OS and “MAMP” on Mac OS.

Web server

The web server handles users’ requests and provides the appropriate responses. It uses the HyperText Transfer Protocol (HTTP).

The most used HTTP server is Apache, but you can also find Nginx or IIS (for Microsoft).

Database

The database layer role is to store data that can be queried by the users. You can use a variety of database management system (DBMS) like MySQL, MariaDB, PostgreSQL and even NoSQL database like MongoDB.

Scripting

The programming language is used to generate dynamic pages on users’ requests.

The most used scripting language is PHP, but you can also use Perl or Python as well.

visual representation of LAMP stack

How to build a LAMP stack

There are two ways you can follow to build a LAMP stack environment on your own computer:

  1. Build from scratch.
  2. Use a bundled solution.

1. Build from scratch

The first way is mostly used by people who need more customization or are on GNU/Linux. It consists of separately installing each piece of software needed, except of course the OS.

2. Use a bundled solution

The second way, the easiest one and mostly used on Windows, consists of installing a package or a bundle that contains everything you need. Among bundled solutions we have WAMP Server, Laragon (Windows), MAMP (Mac, Windows), and XAMPP (cross-platform).

What’s your preferred way?