1. Home
  2. Knowledge Base
  3. LAMP Stack Installation (Ubuntu)

LAMP Stack Installation (Ubuntu)

🔍 What is a LAMP Stack?
LAMP
 is a widely used open-source web development stack that provides the foundation to run dynamic websites and web applications. It consists of four key components, each representing a layer of the stack:

LetterComponentDescription
LLinuxThe operating system (OS) layer. It provides the base platform for all the other components. Popular distributions include Ubuntu, AlmaLinux, Debian, CentOS, etc.
AApacheThe web server that handles HTTP requests and serves content (like HTML, PHP) to users via browsers.
MMariaDB / MySQLThe database management system (DBMS) that stores and retrieves application data efficiently. In this KB, we use MariaDB, a drop-in replacement for MySQL.
PPHPThe server-side scripting language that processes dynamic content, communicates with the database, and generates HTML for browsers.

Why use LAMP?

  • Open-source and free
  • Easy to set up
  • Highly customizable
  • Large community support
  • Widely supported by hosting providers and CMS platforms (WordPress, Joomla, etc.


LAMP Stack Use Cases

  • Hosting content management systems like WordPress, Drupal, or Joomla
  • Developing web applications using Laravel, CodeIgniter, or Symfony
  • Building internal tools or dashboards for businesses
  • Prototyping or launching full-scale web products

Prerequisites

  • Root or sudo access.
  • Clean AlmaLinux 9 or Ubuntu 22.04+ server.
  • Access to the internet.

Steps to LAMP Installation on Ubuntu

1. Update the Package Index

sudo apt upgrade -y
sudo apt upgrade -y

2. Install Apache

sudo apt install apache2 -y

Test Apache:

Open your browser and visit: http://your_server_ip
You should see the Apache2 Ubuntu Default Page.


3. Install MySQL (or MariaDB)

sudo apt install mysql-server -y

Secure MySQL:

sudo mysql_secure_installation

Follow the prompts:

  • Set root password
  • Remove anonymous users
  • Disallow remote root login
  • Remove test database
  • Reload privilege tables

4. Install PHP

sudo apt install php libapache2-mod-php php-mysql -y

Test PHP:

Create a test file:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Visit http://your_server_ip/info.php
You should see the PHP info page.


5. Install phpMyAdmin

sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl -y

➡️ During installation:

  • Select Apache2 using spacebar and press Enter
  • Choose Yes to configure db with dbconfig-common
  • Set a password for the phpMyAdmin MySQL user

Manually Enable phpMyAdmin in Apache

sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

systemctl restart apache2

7. Access phpMyAdmin

Open your browser:
📍 http://your_server_ip/phpmyadmin

Login with:

  • Username: root (or another MySQL user)
  • Password: The one you set

Was this article helpful?