Skip to content

The Moving Parts

BookStack is four things working together. None of them is exotic, and knowing which one holds what will save you real time the first time something misbehaves.

1. The application: PHP code in a folder

BookStack itself is a web application written in PHP (on the Laravel framework), living in a folder on the server — by convention /var/www/bookstack. The folder holds the program, your uploaded images under public/uploads, page attachments under storage/uploads, and the error log at storage/logs/laravel.log, which chapter 14 will teach you to read first and trust over the friendly error page.

On its own the code serves nothing. PHP only runs when a web server hands it a request — which brings us to the parts around it.

2. The web server: the front door

Apache or Nginx receives each visitor's request, serves the static files (images, stylesheets) directly, and passes page requests to PHP. It also owns the address your BookStack answers to and, in a real deployment, the TLS certificate that makes it HTTPS. Chapter 3's lab took a declared shortcut here: PHP's own built-in development server stood in for Apache. It proves the application works; it is not what you would leave running for a group.

3. The database: where the words live

Everything that matters — every page, book, chapter, shelf, user, role, permission and revision — lives in a MySQL or MariaDB database, in a few dozen tables. Images are the exception: the database holds their records, but the image files themselves sit in public/uploads on disk. This split is why chapter 10's backup has two halves: a database dump alone does not contain your pictures, and the picture folders alone do not contain your words.

MariaDB 10.6 or newer, or MySQL 8.0 or newer, is required. The lab used MariaDB 10.11. When the database stops, BookStack stops entirely — there is no read-only degraded mode worth the name.

4. The .env file: the one settings file

In the root of the application folder sits a plain-text file named .env. It holds the settings the code reads at startup: the site's address (APP_URL), the database name, user and password, the mail settings, and APP_KEY — a random key the application encrypts sensitive data with. Treat .env as a secret: it contains your database password in plain text. Treat APP_KEY as permanent: it is baked into encrypted values, and changing it later breaks them, which is why chapter 10's restore instructions insist on keeping the old one.

How a page view flows

A reader asks for a page. The web server passes the request to PHP; PHP reads the .env settings, asks the database for the page and for what this reader is allowed to see, renders the page, and hands it back. Every "why can't I see it?" question in BookStack is answered somewhere along that chain — and chapter 8 explains the permission step in the middle of it.

Check: the four parts, named

php --version          # the language runtime
mysql --version        # the database client
ls /var/www/bookstack  # the application folder
cat /var/www/bookstack/.env | head
                       # the settings (secret - do not share)

If you can say which part each line names, you know enough to install.