How to Install LAMP Stack with MariaDB on Ubuntu 26.04
A LAMP stack is a group of open-source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL or MariaDB database, and dynamic content is processed by PHP.
Update the System
First, check for any pending system upgrades by running the following command,
apt update
apt upgrade
Install Apache
To install Apache along with its utilities, run the following command,
apt install -y apache2 apache2-utils
Next, check the status of Apache by running,
systemctl status apache2
Output:
root@server:~# systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset: >
Active: active (running) since Fri 2026-04-24 17:51:56 UTC; 38s ago
Invocation: 4ca1ac2a12b14bd3a2aeb20e27f4fefe
Docs: https://httpd.apache.org/docs/2.4/
Main PID: 3917 (apache2)
Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes>
Tasks: 55 (limit: 8826)
Memory: 5.7M (peak: 5.8M)
CPU: 244ms
CGroup: /system.slice/apache2.service
├─3917 /usr/sbin/apache2 -k start -DFOREGROUND
├─3934 /usr/sbin/apache2 -k start -DFOREGROUND
└─3935 /usr/sbin/apache2 -k start -DFOREGROUND
If Apache is not active, you can start it using the following command,
systemctl start apache2
Use the following command to enable Apache to start automatically at boot time,
systemctl enable apache2
You can confirm the Apache2 version with the following command,
apache2 -v
Output:
root@server:~# apache2 -v
Server version: Apache/2.4.66 (Ubuntu)
Server built: 2026-03-05T17:18:22
Enable Firewall
We will open the HTTP and HTTPS ports in the firewall so the Apache web server can be accessed.
Allow the HTTP and HTTPS ports by running the following command,
ufw allow http
ufw allow https
To verify if it's working, open your server's IP address in a browser. You should see the Apache default welcome page displayed.
http://ip-address
Note: Replace ip-address with actual IP Address

Install MariaDB Server
Install MariaDB server, run the below command:
apt install mariadb-server mariadb-client -y
Once the installation is complete, check the status of MariaDB by running,
systemctl status mariadb
If MariaDB is not active, you can start it using the following command,
systemctl start mariadb
Use the following command to enable MariaDB to start automatically at boot time,
systemctl enable mariadb
Next, MariaDB Security Setup,
mariadb-secure-installation
- Set Root Password: Yes
- Remove Anonymous Users: Yes
- Disallow Remote Root Login: Yes
- Remove Test Database: Yes
- Reload Privilege Tables: Yes
Log in to MariaDB, use the following command,
mariadb -u root -p
To exit from MariaDB.
exit
Check the MariaDB version, run the following command:
mariadb --version
Output:
root@server:~# mariadb --version
mariadb from 11.8.6-MariaDB, client 15.2 for debian-linux-gnu (x86_64) using EditLine wrapper
Install PHP
PHP 8.5 is the default version of PHP that would be installed on Ubuntu 26.04.
Install PHP and Required Extensions using below command,
apt install php php-mysql php-mbstring php-gd php-xml php-curl php-zip -y
Enable the Apache PHP module and restart the Apache web server with the following commands,
a2enmod php8.5
systemctl restart apache2
Check the PHP version with the following command,
php --version
Test PHP
To test PHP scripts, create an info.php file in the document root directory with the following content,
nano /var/www/html/info.php
Add the following to the file.
<?php phpinfo(); ?>
To verify, enter the following link in a web browser,
http://ip-address/info.php
Note: Replace ip-address with actual IP Address

Once verified, remove the info.php file to avoid any security risks:
rm /var/www/html/info.php
Run PHP-FPM with Apache [Optional]
FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with additional features for heavy-loaded sites.
NOTE: This step is optional.
Next, install PHP-FPM:
apt install php8.5-fpm
Enable proxy_fcgi and setenvif module.
a2enmod proxy_fcgi setenvif
Now, enable the Apache php8.5-fpm configuration,
a2enconf php8.5-fpm
Restart Apache with the following command,
systemctl restart apache2
Enable php-fpm.
systemctl enable php8.5-fpm
Start php-fpm.
systemctl start php8.5-fpm
To check the status of php-fpm.
systemctl status php8.5-fpm
Output:
root@server:~# systemctl status php8.5-fpm
● php8.5-fpm.service - The PHP 8.5 FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php8.5-fpm.service; enabled; prese>
Active: active (running) since Fri 2026-04-24 18:08:23 UTC; 48s ago
Invocation: f53662631eae4762b9fe5ae56bd39338
Docs: man:php-fpm8.5(8)
Main PID: 17893 (php-fpm8.5)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0.00>
Tasks: 3 (limit: 8826)
Memory: 11.2M (peak: 12.7M)
CPU: 211ms
CGroup: /system.slice/php8.5-fpm.service
├─17893 "php-fpm: master process (/etc/php/8.5/fpm/php-fpm.conf)"
├─17894 "php-fpm: pool www"
└─17895 "php-fpm: pool www"
Now, you have successfully installed the LAMP stack (Apache, MariaDB, and PHP 8.5) on Ubuntu 26.04.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS