How to Set Up a LAMP Stack on Ubuntu 26 LTS

Linux Basics

By Jennifer Webb

Updated on Jun 02, 2026

How to Set Up a LAMP Stack on Ubuntu 26 LTS

Learn how to install a LAMP stack on Ubuntu 26 LTS with Apache, MariaDB, PHP. Follow this step-by-step guide to set up a secure web server for WordPress, Laravel, and other PHP applications.

Introduction

A LAMP stack is one of the most popular ways to host websites and web applications on Linux servers. The term LAMP stands for Linux, Apache, MariaDB, and PHP, which together provide everything needed to serve web pages, process dynamic content, and store application data.

Whether you're deploying a WordPress website, a Laravel application, a custom PHP project, or an internal business portal, a LAMP stack offers a reliable and well-tested foundation. Ubuntu 26 LTS makes the setup process straightforward by providing stable package repositories and long-term security updates.

In this tutorial, we'll walk through the complete installation process on Ubuntu 26 LTS. We'll install Apache, MariaDB, and PHP, verify that each component is working correctly, and finish by securing the website with a free SSL certificate from Let's Encrypt.

Prerequisites

Before starting, make sure you have:

  • dedicated server running Ubuntu 26 LTS
  • Root access or a user with sudo privileges
  • A stable internet connection

First, connect to your server via SSH:

ssh username@server-ip

Replace username and server-ip with your actual server details.

Step 1: Update the Server

It's always a good idea to update existing packages before installing new software.

Run:

sudo apt update && sudo apt upgrade -y

Step 2: Install Apache Web Server

Apache is one of the most widely used web servers in the world and remains a solid choice for hosting websites.

Install Apache with:

sudo apt install apache2 -y

After installation, start and enable the service:

sudo systemctl enable --now apache2

Check its status:

sudo systemctl status apache2

You should see a message showing the service is active and running.

Step 3: Allow HTTP and HTTPS Through the Firewall

If Ubuntu's firewall is enabled, you'll need to allow web traffic.

View available Apache profiles:

sudo ufw app list

Allow both HTTP and HTTPS traffic:

sudo ufw allow 'Apache Full'

Verify the rule:

sudo ufw status

Step 4: Verify Apache Installation

Open your browser and visit:

http://your-server-ip

You should see the default Apache welcome page.

If the page loads successfully, Apache is working correctly.

Step 5: Install MariaDB Database Server

MariaDB is the default database server in Ubuntu and is fully compatible with MySQL.

Install it with:

sudo apt install mariadb-server -y

Enable and start the service:

sudo systemctl enable --now mariadb

Check the service status:

sudo systemctl status mariadb

Step 6: Install PHP

PHP is responsible for processing dynamic content and powering applications such as WordPress, Laravel, Magento, and many others.

Install PHP along with commonly used extensions:

sudo apt install php php-cli php-common php-mysql php-curl php-gd php-mbstring php-xml php-zip php-intl php-bcmath libapache2-mod-php -y

Check the installed version:

php -v

Output:

PHP 8.5.4 (cli) (built: May 25 2026 12:19:37) (NTS)
Copyright (c) The PHP Group
Built by Ubuntu
Zend Engine v4.5.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.4, Copyright (c), by Zend Technologies

Ubuntu 26 LTS ships with a modern PHP release, so the exact version may vary depending on updates available in the repositories.

Step 7: Test PHP Processing

Create a test file inside Apache's web root:

sudo nano /var/www/html/info.php

Add the following content:

<?php
phpinfo();
?>

Save the file and exit.

Now visit:

http://your-server-ip/info.php

If PHP is working correctly, you'll see a page displaying detailed PHP configuration information.

Once you've confirmed everything works, remove the file for security reasons:

sudo rm /var/www/html/info.php

Step 8: Verify Database Connectivity

Log into MariaDB:

sudo mariadb

Check the database version:

SELECT VERSION();

Example output:

+------------------------------+
| VERSION()                    |
+------------------------------+
| 11.8.6-MariaDB-5 from Ubuntu |
+------------------------------+
1 row in set (0.000 sec)

Exit the database:

EXIT;

Common Service Management Commands

Start Apache:

sudo systemctl start apache2

Stop Apache:

sudo systemctl stop apache2

Restart Apache:

sudo systemctl restart apache2

Check Apache status:

sudo systemctl status apache2

Start MariaDB:

sudo systemctl start mariadb

Restart MariaDB:

sudo systemctl restart mariadb

Check MariaDB status:

sudo systemctl status mariadb

Final Thoughts

A LAMP stack remains one of the simplest and most reliable ways to host websites on Linux. With Apache handling web requests, MariaDB storing data, and PHP processing dynamic content, you have everything needed to run most modern web applications.

Once your LAMP stack is ready, you can move on to installing WordPress, Laravel, Magento, Drupal, or any other PHP based application on your Ubuntu 26 LTS server.

How to Set Up a LAMP Stack on Ubuntu 26 LTS - HostnExtra