BookStack¶
Prefer one command? Try the BookStack Playbook
BookStack is a simple, self-hosted, easy-to-use platform for organising and storing information (wiki).
BookStack is specially designed to allow new users with basic word-processing skills to get involved in creating content. However, it offers advanced power features for users who need them. The BookStack Playbook automates these instructions. Example output throughout this guide is abbreviated.
Prerequisites¶
We're using PHP in the stable version 8.4:
[isabell@moondust ~]$ uberspace tool php version set 8.4
OK: Set version of php to 8.4
You'll need your MariaDB credentials:
[isabell@moondust ~]$ my_print_defaults client
--default-character-set=utf8mb4
--user=isabell
--password=MySuperSecretPassword
Installation¶
To install BookStack, clone the release branch of the official repository one level above your DocumentRoot using Git.
[isabell@moondust ~]$ cd ~/www
[isabell@moondust www]$ git clone https://source.bookstackapp.com/bookstack.git bookstack --branch release --single-branch
Cloning into 'bookstack'...
remote: Enumerating objects: 53, done.
[…]
[isabell@moondust www]$
cd into your BookStack directory and install the necessary dependencies using Composer.
[isabell@moondust ~]$ cd ~/www/bookstack
[isabell@moondust bookstack]$ composer install --no-dev --no-interaction --prefer-dist
Loading composer repositories with package information
Installing dependencies from lock file
Package operations: 103 installs, 0 updates, 0 removals
[…]
Configuration¶
We suggest you use an additional database for BookStack to save your data. You have to create this database first.
[isabell@moondust ~]$ mysql -e "CREATE DATABASE ${USER}_bookstack"
Copy the sample configuration file .env.example.
[isabell@moondust ~]$ cd ~/www/bookstack
[isabell@moondust bookstack]$ umask 077
[isabell@moondust bookstack]$ cp .env.example .env
[isabell@moondust bookstack]$ chmod 600 .env
Use an editor of your choice to edit the .env file and change the values of:
DB_DATABASEDB_USERNAMEDB_PASSWORDAPP_URL
If you make use of sendmail you will need to adapt the command flags with:
MAIL_SENDMAIL_COMMAND="/usr/bin/sendmail -t"
Example configuration:
APP_URL=https://isabell.uber.space
DB_HOST=localhost
DB_DATABASE=isabell_bookstack
DB_USERNAME=isabell
DB_PASSWORD=MySuperSecretPassword
MAIL_DRIVER=sendmail
MAIL_SENDMAIL_COMMAND="/usr/bin/sendmail -t"
MAIL_FROM_NAME="BookStack"
MAIL_FROM=isabell@uber.space
To make your BookStack installation safe, you need to create a unique application key (a random, 32-character string used e.g. to encrypt cookies).
[isabell@moondust ~]$ cd ~/www/bookstack
[isabell@moondust bookstack]$ php artisan key:generate
**************************************
* Application In Production! *
**************************************
Do you really wish to run this command? (yes/no) [no]:
> yes
Application key set successfully.
Now use the following command to create and populate the tables in your database.
[isabell@moondust ~]$ cd ~/www/bookstack
[isabell@moondust bookstack]$ php artisan migrate
**************************************
* Application In Production! *
**************************************
Do you really wish to run this command? (yes/no) [no]:
> yes
Migration table created successfully.
[…]
Before publishing the site, replace the default administrator. Follow the prompts and choose your own name, email address, and strong password:
[isabell@moondust ~]$ cd ~/www/bookstack
[isabell@moondust bookstack]$ php artisan bookstack:create-admin --initial
[...]
Admin account with email "isabell@uber.space" successfully created!
The --initial option replaces the default administrator. Complete this step before exposing the application.
Remove your unused DocumentRoot and create a new symbolic link to the BookStack/public directory.
[isabell@moondust ~]$ cd ~/www
[isabell@moondust www]$ rm -f html/nocontent.html; rmdir html
[isabell@moondust www]$ ln -s bookstack/public html
Route the standard document root through Apache, then open your site and log in:
[isabell@moondust ~]$ uberspace web backend add "${USER}.uber.space/" apache --force --wait
[...]
OK: Your webserver configuration has been adapted
Debugging¶
Inspect ~/www/bookstack/storage/logs/laravel.log for application errors. Check .env database credentials and APP_URL if installation or login fails. Only the public directory should be exposed through html; never serve the application root.
For password recovery, use Forgot password? on the login page. Check the email configuration if the message does not arrive. See the administration commands for recovery options over SSH.
Updates¶
Note
Check the update feed regularly to stay informed about the newest version. Detailed information on releases is posted on the BookStack blog.
Read the upstream update instructions for version-specific steps. Updates are manual. Enable maintenance mode and back up the database, .env, uploads, and application files before updating:
[isabell@moondust ~]$ cd ~/www/bookstack
[isabell@moondust bookstack]$ php artisan down
[...]
[isabell@moondust bookstack]$ umask 077
[isabell@moondust bookstack]$ mysqldump --single-transaction "${USER}_bookstack" > "$HOME/bookstack-database-$(date +%Y%m%d-%H%M%S).sql"
[isabell@moondust bookstack]$ tar -czf "$HOME/bookstack-files-$(date +%Y%m%d-%H%M%S).tar.gz" -C "/var/www/virtual/$USER" bookstack
Stop if either backup fails. Keep a copy outside the Asteroid. Update from the stable release branch:
[isabell@moondust ~]$ cd ~/www/bookstack
[isabell@moondust bookstack]$ git pull --ff-only origin release
From https://github.com/BookStackApp/BookStack
* branch release -> FETCH_HEAD
[…]
[isabell@moondust bookstack]$ composer install --no-dev --no-interaction --prefer-dist
[…]
Next, start the actual migration.
[isabell@moondust ~]$ cd ~/www/bookstack
[isabell@moondust bookstack]$ php artisan migrate
[…]
[isabell@moondust bookstack]$
After updating your installation you should clean the cache to prevent errors.
[isabell@moondust ~]$ cd ~/www/bookstack
[isabell@moondust bookstack]$ php artisan cache:clear
Cache cleared successfully.
[isabell@moondust bookstack]$ php artisan config:clear
Configuration cache cleared successfully.
[isabell@moondust bookstack]$ php artisan view:clear
Compiled views cleared!
[isabell@moondust bookstack]$ php artisan up
[...]
Verify login and reading/editing a page after updating. A rollback must restore matching application files and the database together.