The Free Encyclopedia

Building a Custom Wiki Engine

Revision as of Jun 27, 2026 02:49 by albert.

You don't need MediaWiki to run a wiki. A few hundred lines of PHP over MariaDB gives you a fast, custom encyclopedia you fully control — the approach behind the wiki you're reading.

Architecture

TLS (edge) → web server → public/index.php  (front controller)
                            ├── lib/   (router, model, markdown, layout)
                            └── views/ (article, edit, history, search, ...)
config.php  ← DB credentials, kept OUTSIDE the web root
DB tables: pages · revisions · categories · page_categories · media · users

Core features to build

  • Markdown rendering (e.g. Parsedown) with <a class="wikilink new" href="/wiki/wiki_links">wiki links</a> and an auto table of contents.
  • Revision history — store every edit as a row; diff two revisions.
  • Categories, infoboxes, full-text search, image uploads.
  • Public read, single-admin edit — a hashed login, CSRF tokens, and prepared statements (Securing a Public PHP App).

Why roll your own

Custom engine Off-the-shelf
Exactly your look & features Generic theme to fight
Tiny, auditable codebase Large attack surface
Any storage you like Its schema, its rules

A wiki is mostly CRUD + Markdown + links. Building it yourself is a great weekend project and a working secure-PHP reference.

Related: Securing a Public PHP App · Apache Name-Based Virtual Hosts on One Server · MariaDB Socket Auth vs TCP Users