How to Install LAMP Stack with MariaDB on Ubuntu 25.10
A LAMP stack is a popular set of open-source software used to host dynamic websites and web applications.
It stands for Linux, Apache, MariaDB/MySQL, and PHP — all of which work together to serve modern web content efficiently.
Update the System
Start by updating and upgrading your system to ensure all packages are up to date.
apt update
apt upgrade
Install Apache Web Server
Install Apache and its utilities:
apt install -y apache2 apache2-utils
Output:
root@server:~# apt install -y apache2 apache2-utils
apache2 is already the newest version (2.4.64-1ubuntu3).
apache2-utils is already the newest version (2.4.64-1ubuntu3).
Summary:
Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 1
Check Apache status:
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 Tue 2025-10-21 20:15:30 UTC; 3min 19s ago
Invocation: 4a917750049f4add95bb34eea4239f3a
Docs: https://httpd.apache.org/docs/2.4/
Main PID: 9332 (apache2)
Tasks: 55 (limit: 8799)
Memory: 5M (peak: 5.2M)
CPU: 175ms
CGroup: /system.slice/apache2.service
├─9332 /usr/sbin/apache2 -k start
├─9334 /usr/sbin/apache2 -k start
└─9335 /usr/sbin/apache2 -k start
Oct 21 20:15:30 server systemd[1]: Starting apache2.service - The Apache HTTP S>
Oct 21 20:15:30 server apachectl[9331]: AH00558: apache2: Could not reliably de>
Oct 21 20:15:30 server systemd[1]: Started apache2.service - The Apache HTTP Se>
lines 1-17/17 (END)
If Apache isn’t active, start it:
systemctl start apache2
Enable Apache to start automatically at boot:
systemctl enable apache2
Check Apache version:
apache2 -v
Output:
root@server:~# apache2 -v
Server version: Apache/2.4.64 (Ubuntu)
Server built: 2025-09-03T14:58:51
Enable Firewall Rules
Allow HTTP and HTTPS traffic through the firewall:
ufw allow http
ufw allow https
Verify by opening your server’s IP in a browser:
http://your-server-ip
Note: Replace
your-server-ipwith your actual server IP.
You should see the Apache default page confirming successful setup.

Install MariaDB Server
Install MariaDB packages:
apt install mariadb-server mariadb-client mariadb-client-compat -y
Check MariaDB status:
systemctl status mariadb
Output:
root@server:~# systemctl status mariadb
● mariadb.service - MariaDB 11.8.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: >
Active: active (running) since Tue 2025-10-21 20:25:23 UTC; 18s ago
Invocation: e9fd7009577f47bdad863cd868827b60
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 10614 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 14 (limit: 58076)
Memory: 93.2M (peak: 97.6M)
CPU: 5.337s
CGroup: /system.slice/mariadb.service
└─10614 /usr/sbin/mariadbd
Oct 21 20:25:20 server mariadbd[10614]: 2025-10-21 20:25:20 0 [Note] Plugin 'ws>
Oct 21 20:25:20 server mariadbd[10614]: 2025-10-21 20:25:20 0 [Note] InnoDB: Lo>
Oct 21 20:25:20 server mariadbd[10614]: 2025-10-21 20:25:20 0 [Note] InnoDB: Bu>
Oct 21 20:25:22 server mariadbd[10614]: 2025-10-21 20:25:22 0 [Note] Server soc>
Oct 21 20:25:22 server mariadbd[10614]: 2025-10-21 20:25:22 0 [Note] mariadbd: >
Oct 21 20:25:22 server mariadbd[10614]: 2025-10-21 20:25:22 0 [Note] /usr/sbin/>
Oct 21 20:25:22 server mariadbd[10614]: Version: '11.8.3-MariaDB-1build1 from U>
Oct 21 20:25:23 server systemd[1]: Started mariadb.service - MariaDB 11.8.3 dat>
Oct 21 20:25:23 server /etc/mysql/debian-start[10643]: Checking for insecure ro>
lines 1-23
If inactive, start and enable it:
systemctl start mariadb
systemctl enable mariadb
Secure MariaDB Installation
Run the secure installation script to improve MariaDB security:
mysql_secure_installation
You’ll be prompted to:
- Set a root password
- Remove anonymous users
- Disallow remote root login
- Remove test databases
- Reload privilege tables
After completion, log in to MariaDB:
mariadb -u root -p
Exit from MariaDB:
exit
Check version:
mariadb --version
Output:
mariadb from 11.5.2-MariaDB, client 15.2 for debian-linux-gnu (x86_64)
Install PHP
Install PHP and required extensions:
sudo apt update
sudo apt install -y software-properties-common ca-certificates lsb-release apt-transport-https
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
sudo apt install -y php8.4
sudo apt install php8.4-mysql -y
Restart Apache:
systemctl restart apache2
Check PHP version:
php -v
Output:
root@server:~# php -v
PHP 8.4.11 (cli) (built: Aug 13 2025 01:43:48) (NTS)
Copyright (c) The PHP Group
Built by Ubuntu
Zend Engine v4.4.11, Copyright (c) Zend Technologies
with Zend OPcache v8.4.11, Copyright (c), by Zend Technologies
Test PHP Processing
Create a test file to verify PHP functionality:
nano /var/www/html/info.php
Add the following content:
<?php phpinfo(); ?>
Open your browser and navigate to:
http://your-server-ip/info.php
You should see the PHP info page.

Once verified, remove the test file for security:
rm /var/www/html/info.php
Conclusion
You’ve successfully installed the LAMP Stack — Apache, MariaDB, and PHP 8.3 — on Ubuntu 25.10.
Your server is now ready to host and serve dynamic PHP-based applications such as WordPress, Drupal, and more.
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