Preparation

Chapter 1 — Overview & Planning

Before installing anything, it pays to understand what a web server stack actually is, how the components talk to each other, and which options are available at each layer. Debian 12 Bookworm is an excellent platform for a web server — stable, well-supported until 2028, and with first-class packages for every component covered in this series.

This chapter gives you the mental model you need before the hands-on installation begins in Chapter 2. Even if you've run web servers before, the component comparison tables are worth keeping as a reference.

What Is a Web Stack?

A web stack is a collection of software layers that work together to serve web pages to visitors. Each layer has a distinct responsibility, and they communicate in a well-defined sequence every time a browser makes a request.

Browser Chrome, Firefox, Safari — sends HTTP requests, renders HTML
↕ HTTP / HTTPS
Web Server Apache / Nginx — receives requests, serves files or passes to PHP
↕ FastCGI / PHP-FPM
Application Layer PHP (or Python, Node.js) — executes logic, builds dynamic responses
↕ PDO / MySQLi
Database MySQL / MariaDB / PostgreSQL — stores and retrieves data
↕ kernel / filesystem
Operating System Debian 12 Bookworm — manages processes, networking, storage

When a visitor loads a page, the browser sends an HTTP request to the web server. If the request is for a static file (an image, CSS, JavaScript) the web server sends it directly. If it's for a dynamic page (a PHP script), the web server hands the request to PHP, which runs the script, queries the database if needed, builds the HTML response, and sends it back up the chain to the browser.

LAMP and LEMP are the two traditional acronyms for this stack on Linux. LAMP = Linux + Apache + MySQL + PHP. LEMP = Linux + (E)Nginx + MySQL + PHP. This series covers both web server options so you can make an informed choice.

Component Options at Each Layer

Web Server — Apache vs Nginx

FeatureApacheNginx
.htaccess per-directory config✔ Yes — config in each folder✘ No — all config in server files
PHP handlingmod_php (embedded) or PHP-FPMPHP-FPM only (external process)
Static file performanceGoodExcellent — event-driven, low memory
Concurrent connectionsGood (worker/event MPM)Excellent — handles thousands with ease
Configuration styleDeclarative + .htaccess overridesBlock-based, all in one place
Documentation & communityVast — decades of examples onlineLarge and growing
Reverse proxy / load balancingSupported (mod_proxy)First-class feature
Best forShared hosting, PHP apps with .htaccess, WordPressHigh-traffic sites, microservices, static sites
Debian packageapache2nginx

Recommendation for this site: Apache is the better match for Philip's Learning Blog — it supports .htaccess out of the box, which is what the existing site uses, and it's the most widely documented option for PHP/MySQL setups. Chapter 2 covers both in full.

Database — MySQL vs MariaDB vs PostgreSQL

FeatureMySQL 8MariaDB 10.xPostgreSQL 15
Drop-in MySQL replacement✔ (it is MySQL)✔ Mostly yes✘ Different SQL dialect
PHP PDO support✔ pdo_mysql✔ pdo_mysql✔ pdo_pgsql
Performance (reads)ExcellentExcellentGood (better for complex queries)
JSON supportStrongGoodExcellent (JSONB)
Fully open sourceCommunity Edition only✔ Yes✔ Yes
Debian Bookworm packageMySQL APT repo requiredmariadb-server (in main repo)postgresql (in main repo)
Best forMySQL-specific apps, full MySQL compatibilityWordPress, general PHP apps, MySQL migrationComplex queries, data integrity, GIS
Note: MariaDB is available directly from Debian's main repository with no extra setup — just apt install mariadb-server. MySQL requires adding the MySQL APT repository first. For most PHP-based sites (including this one) MariaDB is a seamless and simpler choice.

Application Layer — PHP versions

Debian 12 Bookworm ships PHP 8.2 in its main repository — a modern, well-supported version. PHP 8.3 is available via the sury.org third-party repository if you need it. This series uses PHP 8.2 from the Debian repo unless otherwise specified.

VersionSourceSecurity SupportNotes
PHP 8.2Debian main repoUntil Dec 2026Recommended — no extra repo needed
PHP 8.3sury.org PPAUntil Nov 2027Latest stable — needs extra repo
PHP 8.1sury.org PPAUntil Dec 2025Avoid for new installs

Which Stack Should You Choose?

Running a PHP site (WordPress, Laravel, custom PHP)
LAMP — Apache + MariaDB + PHP 8.2. The most documented combination with the best ecosystem support.
High-traffic site or reverse proxy needed
LEMP — Nginx + MariaDB + PHP-FPM. Nginx handles thousands of simultaneous connections with lower memory than Apache.
Just want something running quickly for testing
XAMPP — one installer, everything included. Covered in Chapter 7. Not recommended for production.
Philip's Learning Blog (this site)
Apache + MySQL (or MariaDB) + PHP 8.2. The existing .htaccess config, PDO queries, and admin interface are all built for this combination.

Prerequisites

Before starting Chapter 2, make sure the following are in place on your Debian 12 Bookworm machine:

1. System is up to date

Terminal
$ sudo apt update && sudo apt full-upgrade -y Reading package lists... Done Building dependency tree... Done ...

2. Essential tools installed

Terminal
$ sudo apt install -y curl wget gnupg2 ca-certificates lsb-release apt-transport-https Reading package lists... Done ...

3. Know your machine's IP address

Terminal
$ ip addr show | grep "inet " | grep -v 127.0.0.1 inet 192.168.1.50/24 brd 192.168.1.255 scope global eth0 # You'll use this IP to test the web server from another machine on the network

4. sudo access confirmed

Terminal
$ sudo whoami root # If this returns "root" you have the access you need # If philip is not in the sudo group: su -c "usermod -aG sudo philip" root
About the installation media error: If you see errors about a CD-ROM source when running apt update, open /etc/apt/sources.list with sudo vi /etc/apt/sources.list and comment out any line beginning with deb cdrom:// by adding a # at the start. Save and re-run sudo apt update.

What This Series Covers

1
Overview & Planning
Stack anatomy, component choices, comparison tables, prerequisites — this chapter
2
Web Server
Apache and Nginx — install, configure, virtual hosts, testing
3
Database
MySQL, MariaDB, PostgreSQL — install, harden, create users and databases
4
PHP
Install PHP 8.2, configure php.ini, essential extensions, test with a live script
5
SSL / HTTPS
Let's Encrypt with Certbot for public domains, self-signed certs for local dev
6
Firewall & Security
UFW rules, fail2ban, file permissions, hiding version information
7
XAMPP
All-in-one alternative — install, configure, pros and cons vs the manual stack
Next: Chapter 2 — Web Server
Chapter 2 covers the full installation and configuration of both Apache and Nginx on Debian 12 Bookworm — including virtual hosts, document roots, enabling/disabling sites, and verifying the server is running correctly. You only need to install one, but both are documented so you can make the right choice for your setup.