Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Deploy Bookstack

Introduction

BookStack is a self-hosted website that is built on top of the Laravel framework, that allows you to create documentation (a Wiki as it were) through the use of Markdown and/or a WYSIWYG.

Demonstration Video

If you are interested in watching a video about Bookstack before going to the effort of setting it up, watch the video below.

Install Steps

Create Docker Compose File

Create a docker-compose.yml file wherever you wish to "install" Bookstack, with the following content:

services:

  bookstack:
    image: lscr.io/linuxserver/bookstack:${BOOKSTACK_VERSION}
    container_name: bookstack
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
        compress: "true"
    depends_on:
      - db
    restart: unless-stopped
    ports:
      - "80:80"
    volumes:
      - ./volumes/bookstack-config:/config
    environment:
      - PUID=2001
      - PGID=2001
      - APP_URL
      - APP_KEY
      - DB_HOST=db
      - DB_PORT=3306
      - DB_USERNAME=${DB_USER}
      - DB_PASSWORD=${DB_PASSWORD}
      - DB_DATABASE=${DB_NAME}

  db:
    image: mariadb:${MARIADB_VERSION}
    container_name: db
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
        compress: "true"
    restart: unless-stopped
    volumes:
      - ./volumes/bookstack-db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
      - MYSQL_DATABASE=${DB_NAME}
      - MYSQL_USER=${DB_USER}
      - MYSQL_PASSWORD=${DB_PASSWORD}

Create .env File

Create the .env file in the same directory as the docker-compose.yml file you created earlier, with the following settings (fill in the values):

COMPOSE_PROJECT_NAME="bookstack"

DB_NAME="bookstack"
DB_USER="bookstack"
DB_PASSWORD=""
DB_ROOT_PASSWORD=""

# Specify the URL that bookstack will be on.
APP_URL="https://bookstack.mydomain.com"

# Specify a random key for Bookstack (Laravel) to use.
# generate with: 
# echo "base64:$(openssl rand -base64 32)"
APP_KEY=""

# Specify the versions
BOOKSTACK_VERSION="24.12.1"
MARIADB_VERSION="10.11-jammy"

Optional - Remap Your User

We told the container to run as user and group 2001 in the docker-compose.yml file. Let's change the user we wish to manage these services with, to use those IDs.

sudo usermod -u 2001 $myManagementUser
sudo groupmod -g 2001 $myManagementUsersGroup

This benefit of doing this is that it will mean that the config files that bookstack generates into the folder it creates at volumes/bookstack-config will be owned by your user, and you can edit them without having to be root or run sudo.

You will need to perform the actions above as a different user to the one being edited, and not have SSH'd in through the user you are wishing to edit. You may find it easier to just create a new user to act as the management user, and assign that user's IDs.

Login

Now go to your server's IP or FQDN in your browser and login with the default credentials which are:

  • user: admin@admin.com
  • password: password

Change your password immediately upon logging in.

References

Last updated: 22nd January 2025
First published: 22nd January 2025

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch