LAMP stack

An open server representing the LAMP stack

LAMP is a collection of open-source software for websites and web applications: Linux, Apache, MySQL or MariaDB, and PHP. It is suitable for WordPress, online stores and business services. For a new project, you can use Ubuntu Server 26.04 LTS and packages from its repositories, after checking that the website supports PHP 8.5. After installation, you need to configure the domain, HTTPS, database access and backups.

What is LAMP?

The name comes from the initials of its four components. They work in layers: the operating system provides resources, the web server receives requests, PHP runs the application, and the database stores data. The components are installed independently and can run on one or several machines.

Components: Linux, Apache, MySQL and PHP

Versions were checked in November 2026 against the Ubuntu package catalogue and security notices. Versions are listed without build suffixes; availability depends on the mirror and architecture.

Component Role Alternatives Version in Ubuntu 26.04
Linux Resources, networking and access permissions Another Linux distribution Ubuntu Server 26.04 LTS, image 26.04.1
Apache HTTP requests, files and invoking PHP Nginx 2.4.66
MySQL Storing and retrieving application data MariaDB; PostgreSQL with application changes 8.4.13
PHP Running server-side code and generating responses Python or Perl for a different application 8.5.4

The catalogue lists MariaDB 11.8.6. MySQL 8.4.13 is listed in the Ubuntu security notice dated 11 November; the package catalogue may take time to catch up. After sudo apt update, run apt policy apache2 mysql-server mariadb-server php8.5 to see which versions are available to your server.

Linux manages resources and access to them. LAMP works on different distributions. Differences between server operating systems are discussed in Windows Server and Linux: when migration pays off.

Apache receives requests, selects a website by its domain, serves static files and passes PHP execution to the configured handler.

MySQL or MariaDB stores data. These are separate database management systems with a shared origin: test any replacement using a copy of the application and database. Hardware requirements are discussed in High-Performance Database Server.

PHP runs code on the server; the browser receives the result. Historically, the letter P can also stand for Perl or Python, but WordPress and other PHP applications require PHP.

How the LAMP stack works

When a WordPress page is opened without a ready-made response in the cache:

  1. The browser sends a request to Apache.
  2. Apache passes execution to PHP.
  3. PHP runs WordPress and requests data from MySQL.
  4. The database returns the data, PHP generates HTML, and Apache sends it to the browser.

mod_php runs PHP inside Apache processes. PHP-FPM manages separate processes to which the web server passes tasks. One reason to choose it is to configure separate handlers for different websites. Below, we use mod_php.

Apache serves existing image files without involving PHP or the database. Caching can also skip some processing steps: performance depends on the application and the configuration of the entire stack.

Get Expert Help
Choosing the Right Equipment

Our specialists will contact you and answer all your questions

I agree to process my personal data

LAMP use cases, advantages and limitations

A laptop and server connected for web request processing

LAMP is used for websites built on WordPress, Joomla and Drupal, online stores, business portals, ticketing systems and test environments. Check the PHP, database and extension requirements for the specific CMS release.

Advantages

  • Open-source software: the core components do not require commercial licences, although maintenance and hardware still cost money.
  • Documentation and community: guides and specialists are available for widely used CMS platforms.
  • Flexibility: you can move the database to a separate machine, add caching or switch to PHP-FPM.
  • Straightforward maintenance: packages are updated using the distribution’s package management tools.

Limitations

On a single machine, Apache, PHP and the database compete for memory, CPU and storage resources. Unrestricted growth in the number of PHP processes can leave the database without enough memory. Failure of the only server takes the entire website offline.

Distributing the load requires a load balancer and consistent handling of sessions and user files. Multiple application instances do not make a single database fault tolerant: scaling requires a separate architecture design.

LAMP, LEMP and other stacks

The choice of stack depends on the application. Compare performance using the same hardware and workload.

Stack Components and differences When to consider it
LAMP Linux, Apache, MySQL or MariaDB, PHP A PHP website suited to Apache’s features and configuration
LEMP Linux, Nginx, MySQL or MariaDB, PHP; usually PHP-FPM A project that uses Nginx, with a team experienced in configuring it
LAPP Linux, Apache, PostgreSQL, the application’s programming language An application designed for PostgreSQL
MEAN / MERN MongoDB, Express, Angular or React, Node.js An application designed in JavaScript; this is a different software foundation
WAMP / MAMP Similar combinations for Windows and macOS; ready-made bundles are available Local development and learning
XAMPP A ready-made bundle of Apache, MariaDB, PHP and Perl for several operating systems Quickly setting up a local environment

Apache supports .htaccess rules when they are allowed by its configuration. For Nginx, these rules must be moved into the server configuration. Switching to LEMP does not fix expensive database queries.

In a browser, localhost refers to the same computer. To reach another machine, you need its network address. Read more in Local network and server.

How to install LAMP on Ubuntu

The following steps install LAMP on a clean Ubuntu Server 26.04 LTS system, the current LTS release at the time of checking. You need sudo privileges and working SSH access. Back up an existing server before making changes. Your CMS, themes and extensions must support PHP 8.5.

Update the package list and installed software:

sudo apt update
sudo apt upgrade

If a restart is required, restart the server and reconnect. We use Ubuntu’s standard repositories.

Apache and the firewall

Install the web server and firewall management tool:

sudo apt install apache2 ufw
sudo systemctl enable --now apache2
sudo systemctl status apache2

Press q to exit. Allow SSH and web traffic. OpenSSH is already installed and uses port 22:

sudo ufw allow OpenSSH
sudo ufw allow 'Apache Full'
sudo ufw enable
sudo ufw status

If SSH uses a different port, allow that port before enabling ufw. For example, port 2222 requires sudo ufw allow 2222/tcp. Check that you can log in from a second terminal while keeping your current session open.


The Apache Full profile opens TCP ports 80 and 443, but HTTPS still needs to be configured. If there is an external firewall, open the ports there too. Read more in TCP/UDP network ports.

Open http://SERVER_ADDRESS/: the default Apache page should appear.

MySQL or MariaDB

Server drives and memory for a database

Choose one database management system. For MySQL, run:

sudo apt install mysql-server
sudo systemctl enable --now mysql
sudo mysql_secure_installation

The utility helps remove anonymous accounts and the test database, restrict remote administrator login and configure password validation. Some of these objects may already be absent.

According to the Ubuntu documentation, the local MySQL root account uses auth_socket by default: access is authenticated through operating system permissions. Open the console:

sudo mysql

Create a separate database and user for the website. Replace the example password with your own unique value:

CREATE DATABASE site_db CHARACTER SET utf8mb4;
CREATE USER 'site_user'@'localhost'
  IDENTIFIED BY 'REPLACE_WITH_A_UNIQUE_PASSWORD';
GRANT ALL PRIVILEGES ON site_db.* TO 'site_user'@'localhost';
EXIT;

Privileges are limited to the site_db database; narrow them further if necessary. Enter the database name, username and password in the CMS.

You can retain administrator root access through sudo. If the administrator needs a password, run ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'NEW_UNIQUE_PASSWORD'; in the MySQL console. Then log in with mysql -u root -p. This is an alternative administration method, not a required installation step.

To use MariaDB instead of MySQL, run sudo apt install mariadb-server, followed by sudo mariadb-secure-installation; open the console with sudo mariadb. Do not use the command containing caching_sha2_password in MariaDB.

On Debian 13, default-mysql-server installs MariaDB through a compatibility package. The tasksel method with the lamp-server task applies only if that task appears in tasksel --list-tasks for your release.

PHP and checking the installation

Install PHP, the Apache module and the MySQL access extension:

sudo apt install php libapache2-mod-php php-mysql
sudo systemctl restart apache2

This uses the Apache module integration described in the Ubuntu PHP guide. PHP-FPM is configured separately.

On a clean server, create /var/www/html/phpinfo.php using sudoedit /var/www/html/phpinfo.php and add:

<?php
phpinfo();

Open http://SERVER_ADDRESS/phpinfo.php. Look for the mysqli or pdo_mysql sections; the Server API field identifies the handler. Delete the file immediately after viewing it: it exposes information about the server.


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

Test the database connection separately when configuring the application. Install any additional extensions required by the CMS.

Get Expert Help
Choosing the Right Equipment

Our specialists will contact you and answer all your questions

I agree to process my personal data

Configuration: virtual hosts and HTTPS

Website directory and Apache configuration

Virtual hosts let you serve multiple domains. On Ubuntu, configuration files are stored in /etc/apache2/sites-available/; a2ensite enables the selected website.

Replace example.com with your domain. Create the directory:

sudo mkdir -p /var/www/example.com/public

Place the application files in it and create the following configuration using sudoedit /etc/apache2/sites-available/example.com.conf:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/example.com/public

    <Directory /var/www/example.com/public>
        Options -Indexes
        AllowOverride None
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>

DocumentRoot is the directory for public files. Here, .htaccess is disabled. If the CMS needs it, allow the required directives and enable mod_rewrite according to its documentation.

sudo a2ensite example.com.conf
sudo apache2ctl configtest

After Syntax OK, run sudo systemctl reload apache2. Point the domain’s DNS records to the server’s address. Before doing so, you can test the host locally: curl -H 'Host: example.com' http://127.0.0.1/.

Certificate and file access

Apache virtual hosts and a secure HTTPS connection

For a domain that points to the server and is accessible over HTTP, configure HTTPS through Let’s Encrypt: install certbot and python3-certbot-apache, then run sudo certbot --apache -d example.com. See the Certbot documentation for details. Enable redirection to HTTPS and test renewal: sudo certbot renew --dry-run. For validation through Apache, make port 80 accessible from outside.

File permissions depend on who updates the application and where it needs write access:

  • for ordinary public directories, a starting point is 755, and for files, 644;
  • make the deployment user the owner of the code; the web server only needs read access;
  • allow PHP to write only to the required upload, cache and temporary directories;
  • apply stricter permissions to files containing passwords while retaining access for the process that needs them;
  • store backups and database dumps outside the website’s public directory.

Do not assign 777 permissions or make every file executable with the recursive command chmod -R 755. Update the operating system and CMS, and close unused ports. Store backups separately and test recovery.


Where to deploy LAMP

Network connections in a data centre

Data centre network infrastructure connects servers. Photo: Brett Sayles / Pexels.

  • A VPS is convenient when starting out: resources can be increased without buying hardware.
  • A dedicated server suits sustained high workloads and situations where you need full control over resources.
  • An on-premises server runs within your own infrastructure, where you provide power, cooling, connectivity and maintenance.

The following ranges can be used for an initial estimate:

  • a small website with moderate traffic: 2 virtual CPU cores, 2–4 GB of memory and 30–60 GB of SSD storage;
  • a growing online store or several websites: 4–8 cores, 8–16 GB of memory and at least 100 GB of SSD storage;
  • a heavily loaded project: 8–16 or more cores, 16–64 GB of memory or more, and SSD or NVMe storage with suitable write latency.

These are guidelines: exact requirements depend on the CMS, database, caching and concurrent requests. Refine them through load testing. Allow storage headroom for data growth and logs.

You can choose hardware from the Servermall server catalogue. For more guidance on selecting hardware, see How to Choose a Server for a Small Business or Office. Choose the model and generation according to the workload.

Frequently asked questions

How does LAMP differ from LEMP?

LAMP uses Apache, while LEMP uses Nginx. PHP and the database can remain the same. Performance depends on the application and configuration.

Which should I choose: MySQL or MariaDB?

Follow the CMS requirements. When migrating, test queries, character encodings and application updates using a copy of the data.

Can I install LAMP on Windows?

You can run a Linux environment through WSL or a virtual machine. WAMP and XAMPP are available for local development. Before publishing, test the website in an environment similar to production.

Is LAMP suitable for WordPress?

Yes, provided the PHP, database and extension versions meet the requirements of the CMS and its modules.

Is the LAMP stack outdated?

LAMP built on supported components is suitable for compatible PHP applications. Operating it requires updates, resource monitoring and backups.


Get Expert Help
Choosing the Right Equipment

Our specialists will contact you and answer all your questions

I agree to process my personal data
Comments
(0)
No comments
Write the comment
I agree to process my personal data

Next news

Be the first to know about new posts and earn 50  €