Learn how to install a LAMP stack on Debian 13 with Apache, MariaDB, and PHP. Follow this step by step guide to prepare a Debian server for WordPress, Laravel, and other PHP applications.
A fresh Debian server provides a clean and stable foundation for hosting websites, applications, and development environments. Whether you're launching a WordPress blog, deploying a Laravel application, or building a custom PHP project, one of the first things you'll need is a web server, a database, and a scripting language working together.
This combination is commonly known as a LAMP stack, which consists of Linux, Apache, MariaDB, and PHP. These technologies have powered websites for decades and continue to be a reliable choice for developers, businesses, and system administrators.
Debian 13 focuses on stability, predictable updates, and long term reliability, making it a popular operating system for production servers. In this guide, we'll install Apache, MariaDB, and PHP, verify that each service is running correctly, and prepare the server for hosting PHP based applications.
Prerequisites
Before starting, make sure you have:
- A dedicated server running Debian 13.
- Root access or a user with sudo privileges
- A stable internet connection
First, connect to your server via SSH:
ssh username@server-ip
Replace username and server-ip with your actual server details.
Step 1: Refresh Package Information
It's always a good idea to update existing packages before installing new software.
Run:
sudo apt update && sudo apt upgrade -y
Step 2: Deploy Apache on Debian 13
Apache is one of the most widely used web servers in the world and remains a solid choice for hosting websites.
Install Apache with:
sudo apt install apache2 -y
Debian ships Apache with a modular configuration layout that separates sites, modules, and global settings into dedicated directories. This approach makes long term server management easier, especially when hosting multiple websites.
sudo systemctl enable --now apache2
Check its status:
sudo systemctl status apache2
You should see a message showing the service is active and running.
Step 3: Allow HTTP and HTTPS Through the Firewall
If Ubuntu's firewall is enabled, you'll need to allow web traffic.
View available Apache profiles:
sudo ufw app list
Allow both HTTP and HTTPS traffic:
sudo ufw allow 'Apache Full'
Verify the rule:
sudo ufw status
Step 4: Verify Apache Installation
Open your browser and visit:
http://your-server-ip
You should see the default Apache welcome page.
If the page loads successfully, Apache is working correctly.
Step 5: Install MariaDB Database Server
MariaDB is the default database server in Ubuntu and is fully compatible with MySQL.
Install it with:
sudo apt install mariadb-server -y
Enable and start the service:
sudo systemctl enable --now mariadb
Check the service status:
sudo systemctl status mariadb
Step 6: Install PHP
PHP is responsible for processing dynamic content and powering applications such as WordPress, Laravel, Magento, and many others.
Install PHP along with commonly used extensions:
sudo apt install php php-cli php-common php-mysql php-curl php-gd php-mbstring php-xml php-zip php-intl php-bcmath libapache2-mod-php -y
Debian automatically integrates PHP with Apache through the libapache2-mod-php package, allowing PHP files to be processed without additional configuration in most deployments.
Check the installed version:
php -v
Output:
PHP 8.5.4 (cli) (built: May 25 2026 12:19:37) (NTS)
Copyright (c) The PHP Group
Built by Ubuntu
Zend Engine v4.5.4, Copyright (c) Zend Technologies
with Zend OPcache v8.5.4, Copyright (c), by Zend Technologies
Ubuntu 26 LTS ships with a modern PHP release, so the exact version may vary depending on updates available in the repositories.
Step 7: Test PHP Processing
Create a test file inside Apache's web root:
sudo nano /var/www/html/info.php
Add the following content:
<?php
phpinfo();
?>
Save the file and exit.
Now visit:
http://your-server-ip/info.php
If PHP is working correctly, you'll see a page displaying detailed PHP configuration information.
Once you've confirmed everything works, remove the file for security reasons:
sudo rm /var/www/html/info.php
Step 8: Verify Database Connectivity
Log into MariaDB:
sudo mariadb
Check the database version:
SELECT VERSION();
Example output:
+------------------------------+
| VERSION() |
+------------------------------+
| 11.8.6-MariaDB-5 from Ubuntu |
+------------------------------+
1 row in set (0.000 sec)
Exit the database:
EXIT;
Common Service Management Commands
Start Apache:
sudo systemctl start apache2
Stop Apache:
sudo systemctl stop apache2
Restart Apache:
sudo systemctl restart apache2
Check Apache status:
sudo systemctl status apache2
Start MariaDB:
sudo systemctl start mariadb
Restart MariaDB:
sudo systemctl restart mariadb
Check MariaDB status:
sudo systemctl status mariadb
Final Thoughts
Debian 13 provides an excellent platform for running PHP based websites and applications. With Apache serving web content, MariaDB managing data, and PHP handling application logic, your server is now ready for production workloads.
From here, you can deploy content management systems such as WordPress, application frameworks like Laravel, or your own custom PHP projects. As your environment grows, consider adding SSL certificates, automated backups, monitoring, and firewall rules to improve security and reliability.

