LAMP Stack Ubuntu 26.04 Installation Guide

Setting up a LAMP Stack Ubuntu server is one of the fastest ways to host PHP-based applications like WordPress, Laravel, Joomla, and Drupal. The LAMP stack combines Linux, Apache, MySQL, and PHP into a complete web hosting environment capable of serving dynamic websites efficiently.

Ubuntu 26.04 ships with updated packages, making the installation process easier and more secure for developers and system administrators.

What Is a LAMP Stack?

A LAMP stack is a popular open-source web server setup consisting of:

  • Linux as the operating system
  • Apache as the web server
  • MySQL for database management
  • PHP for dynamic web content

This combination powers millions of websites worldwide because of its flexibility, stability, and strong community support.


Install Apache Web Server

Start by updating your package index and installing Apache:

sudo apt updatesudo apt install apache2

After installation, verify the service is running:

sudo systemctl status apache2

If UFW firewall is enabled, allow web traffic:

sudo ufw allow 'Apache Full'

You can now open your server IP address in a browser to confirm Apache is working correctly.


Install MySQL Database Server

MySQL handles your application databases and user data. Install it using:

sudo apt install mysql-server

Once installed, run the built-in security script:

sudo mysql_secure_installation

This step helps secure the database server by removing anonymous accounts and disabling insecure settings.

Check the MySQL service status:

sudo systemctl status mysql

Install PHP on Ubuntu 26.04

The next step in configuring your LAMP Stack Ubuntu environment is installing PHP along with Apache integration modules.

Run:

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

Verify the installed PHP version:

php -v

Restart Apache so the PHP module loads properly:

sudo systemctl restart apache2

You can also install additional PHP extensions commonly required by CMS platforms:

sudo apt install php-curl php-xml php-gd php-mbstring php-zip

Configure Apache Virtual Host

Create a dedicated directory for your website:

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

Then create an Apache virtual host configuration file for your domain. This allows Apache to host multiple websites on a single server.

Enable the new site and disable the default configuration:

sudo a2ensite example.comsudo a2dissite 000-default

After testing the configuration, reload Apache:

sudo apache2ctl configtestsudo systemctl reload apache2

Test PHP Processing

Create a simple PHP test file:

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

Open the file in your browser:

http://your_server_ip/info.php

If the PHP information page appears, the server is processing PHP correctly.

For security reasons, delete the file afterward:

sudo rm /var/www/example.com/info.php

Final Thoughts

Building a LAMP Stack Ubuntu server on Ubuntu 26.04 provides a reliable foundation for hosting modern PHP applications and websites. With Apache, MySQL, and PHP properly configured, your server is ready for CMS deployments, custom web applications, and production workloads.

For better security, consider enabling HTTPS with Let’s Encrypt and keeping all packages regularly updated.