Install a LAMP Stack on Debian 10 with Apache and MariaDB

Install a LAMP Stack on Debian 10 with Apache and MariaDB

If you’re staring at a fresh Debian 10 server and wondering why your PHP site just shows a download dialog or a blank page, you’re in the right place.

Before: you have a clean server that can maybe ping Google, but it can’t serve a single dynamic page.
After: you’ll have a working LAMP stack — Linux, Apache, MariaDB, PHP — ready to host WordPress, custom PHP apps, or whatever you’re building.

I’ll walk you through it step by step, using safe commands you can paste in. We’re using MariaDB instead of MySQL, because Debian ships it as a drop-in replacement.

What We’re Doing and Who This Is For

This guide is for you if:

  • You have a Debian 10 server (VPS, dedicated, or local VM).
  • You have a non-root user with sudo privileges.
  • You want to host a PHP-based site or app using Apache and MariaDB.

We’re going to set up the classic LAMP stack:

  • Linux: Debian 10 (already installed).
  • Apache: the web server.
  • MariaDB: database server (used as a MySQL-compatible replacement).
  • PHP: to process dynamic content.

Assumption from the source: you already have a basic firewall set up (UFW) and a sudo-enabled user. If not, handle that first, then come back here.

Step 1: Update Your Package Index (Always Do This First)

Before installing anything, refresh Debian’s package list. This avoids weird version mismatches and missing packages.

Run:

sudo apt update

If this is the first time you’re using sudo in this session, Debian will ask for your user password. That’s just confirming you’re allowed to manage packages.

Let this finish before moving on. If you see errors about network or repositories, fix those first — no point trying to install Apache if apt can’t see the internet.

Step 2: Install Apache Web Server

Apache is one of the most common web servers on the planet. It’s well-documented and has been used for years, which makes it a solid, boring, reliable default. Boring is good for servers.

Install Apache with:

sudo apt install apache2

You’ll be prompted to confirm installation. Press Y, then ENTER to continue.

Once it’s done, Apache will usually start automatically. At this point, the server can serve basic HTML, but your firewall might still be blocking HTTP/HTTPS.

Step 3: Adjust the Firewall (UFW) for Web Traffic

If you followed the initial Debian 10 setup from the same source, you should already have UFW (Uncomplicated Firewall) installed and enabled.

Debian 10 comes with some predefined UFW application profiles. These profiles are shortcuts that open the right ports for common services.

First, list available profiles:

sudo ufw app list

You’ll see something like:

Available applications:
  ...
  WWW
  WWW Full
  WWW Secure
  ...

The WWW profiles are used for web servers:

  • WWW – typically HTTP only.
  • WWW Full – typically HTTP and HTTPS.
  • WWW Secure – usually HTTPS only.

Pick the one that fits what you need right now:

  • If you just need basic HTTP for testing:

bash
sudo ufw allow "WWW"

  • If you’re planning to use HTTPS (recommended long-term):

bash
sudo ufw allow "WWW Full"

You can re-run sudo ufw status to confirm the rules are active.

Why this matters: if the firewall is closed, you can have a excellent Apache config and still see nothing from your browser.

Step 4: Verify Apache Is Running

With Apache installed and the firewall open, let’s check if Apache is actually responding.

On the server itself, you can use systemctl:

sudo systemctl status apache2

You should see something that indicates it’s active (running). If it’s not, you can try starting it:

sudo systemctl start apache2

Now, from your local machine, open a browser and go to:

http://YOUR_SERVER_IP

You should see the default Apache page for Debian (usually a basic “It works” or Debian-branded Apache page). That confirms:

  • DNS or IP is reachable.
  • Firewall is open.
  • Apache is installed and responding.

If you see connection refused or timeout, check:

  • UFW status.
  • That Apache is running.
  • That you’re using the correct IP.

Step 5: Install MariaDB (MySQL-Compatible Database)

LAMP usually means MySQL, but Debian uses MariaDB as a drop-in replacement. For most PHP apps, that works the same — the interface and commands are compatible.

According to the source, the stack we’re building uses MariaDB as the database management system.

While the exact install commands aren’t spelled out in the excerpt, they follow the same pattern as Apache and use apt to install the MariaDB server and tools on Debian 10. Once installed, MariaDB will store your site’s data — users, posts, orders, whatever your app needs.

After you have MariaDB installed and running, keep these in mind as best practices:

  • Create a separate database user for each app.
  • Don’t use the database root user from your application config.
  • Use strong passwords and store them outside version control.

That keeps damage contained if one site gets compromised.

Step 6: Install PHP to Handle Dynamic Content

Right now, Apache can serve static files (HTML, CSS, JS), but not PHP. To get dynamic content (like WordPress or a custom PHP app), you need PHP installed alongside Apache and MariaDB.

In a typical LAMP setup on Debian 10, you would:

  • Install PHP itself.
  • Install PHP’s Apache integration.
  • Install extension(s) for MariaDB so PHP can talk to the database.

The source guide’s goal is to have PHP process dynamic content, using MariaDB to store your site data. Once PHP is installed and wired into Apache, PHP files will be executed instead of being downloaded.

You’ll then be able to:

  • Drop a info.php file in your web root (like /var/www/html) to confirm PHP is running.
  • Install PHP-based apps like WordPress or custom scripts.

If you see PHP code in your browser instead of rendered content, that means Apache isn’t handing .php files to PHP correctly.

Step 7: Basic Safety and Next Steps

A few quick safety notes while you’re working through this:

  • Use sudo, not root directly – reduces the blast radius if you mis-type a command.
  • Firewall first, then services – opening ports with UFW profiles is safer than disabling the firewall.
  • Test as you go – after each major step (Apache, firewall, MariaDB, PHP), test instead of doing everything then trying to debug five things at once.

Once you have Linux + Apache + MariaDB + PHP installed and talking to each other, your Debian 10 server is ready for real workloads:

  • WordPress or other CMS.
  • Custom PHP apps.
  • Internal tools for your company.

If this saved you time, bookmark CrushEdge for more fixes.

No Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.