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.
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.
Component Options at Each Layer
Web Server — Apache vs Nginx
| Feature | Apache | Nginx |
|---|---|---|
| .htaccess per-directory config | ✔ Yes — config in each folder | ✘ No — all config in server files |
| PHP handling | mod_php (embedded) or PHP-FPM | PHP-FPM only (external process) |
| Static file performance | Good | Excellent — event-driven, low memory |
| Concurrent connections | Good (worker/event MPM) | Excellent — handles thousands with ease |
| Configuration style | Declarative + .htaccess overrides | Block-based, all in one place |
| Documentation & community | Vast — decades of examples online | Large and growing |
| Reverse proxy / load balancing | Supported (mod_proxy) | First-class feature |
| Best for | Shared hosting, PHP apps with .htaccess, WordPress | High-traffic sites, microservices, static sites |
| Debian package | apache2 | nginx |
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
| Feature | MySQL 8 | MariaDB 10.x | PostgreSQL 15 |
|---|---|---|---|
| Drop-in MySQL replacement | ✔ (it is MySQL) | ✔ Mostly yes | ✘ Different SQL dialect |
| PHP PDO support | ✔ pdo_mysql | ✔ pdo_mysql | ✔ pdo_pgsql |
| Performance (reads) | Excellent | Excellent | Good (better for complex queries) |
| JSON support | Strong | Good | Excellent (JSONB) |
| Fully open source | Community Edition only | ✔ Yes | ✔ Yes |
| Debian Bookworm package | MySQL APT repo required | mariadb-server (in main repo) | postgresql (in main repo) |
| Best for | MySQL-specific apps, full MySQL compatibility | WordPress, general PHP apps, MySQL migration | Complex queries, data integrity, GIS |
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.
| Version | Source | Security Support | Notes |
|---|---|---|---|
| PHP 8.2 | Debian main repo | Until Dec 2026 | Recommended — no extra repo needed |
| PHP 8.3 | sury.org PPA | Until Nov 2027 | Latest stable — needs extra repo |
| PHP 8.1 | sury.org PPA | Until Dec 2025 | Avoid for new installs |
Which Stack Should You Choose?
Prerequisites
Before starting Chapter 2, make sure the following are in place on your Debian 12 Bookworm machine:
1. System is up to date
2. Essential tools installed
3. Know your machine's IP address
4. sudo access confirmed
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.