A LAMP stack — Linux, Apache, MySQL, and PHP — powers a large portion of the web, including WordPress, Joomla, and countless custom applications. This guide installs all four components on Ubuntu 26.04 LTS.
Tested and valid on:
- Ubuntu 26.04 LTS
Prerequisites
- Ubuntu 26.04 LTS server
- A user with sudo privileges
- UFW firewall enabled
Step 1 – Install Apache
sudo apt update
sudo apt install apache2 -y
sudo ufw allow 'Apache Full'
Step 2 – Install MySQL 9
sudo apt install mysql-server -y
sudo mysql_secure_installation
Step 3 – Install PHP 8.4
Install PHP and the Apache PHP module plus common extensions:
sudo apt install php8.4 libapache2-mod-php8.4 php8.4-mysql php8.4-mbstring php8.4-xml php8.4-curl php8.4-zip -y
Step 4 – Verify PHP Installation
php -v
Create a test file:
echo '' | sudo tee /var/www/html/info.php
Visit http://your_server_ip/info.php then remove it:
sudo rm /var/www/html/info.php
Step 5 – Test MySQL
sudo mysql
SHOW DATABASES;
exit
Step 6 – Enable mod_rewrite
Required by WordPress and most PHP frameworks:
sudo a2enmod rewrite
sudo systemctl restart apache2
Step 7 – Create a Test Database
Set up a database for your application:
sudo mysql
CREATE DATABASE myapp;
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON myapp.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;
exit
Conclusion
Your Ubuntu 26.04 LTS LAMP stack is ready. This foundation supports WordPress, Laravel, Drupal, and virtually any PHP-based application. Next, configure Apache virtual hosts for your domain and add SSL.