BookStack is a simple, self-hosted, user-friendly, and free open-source platform used for storing and organizing information. The BookStack interface is straightforward and intuitive, supporting a WYSIWYG editor, and it organizes content into three basic groups: books, chapters, and pages. It also supports full-text content search and links across books, chapters, and pages.

Useful Links

Installation

System Requirements

  • PHP (>= 8.0.2)

    • Required extensions: OpenSSL, PDO, MBstring, iconv, Tokenizer, GD, MySQL, SimpleXML & DOM.
  • MySQL (>= 5.7 or MariaDB >= 10.2)

    • Used for storing BookStack's content.
  • Git Version Control

    • Used for program updates.
  • Composer (>= v2.0)

    • Used for managing and installing PHP dependencies.
  • A PHP-compatible web server, such as Nginx.

This tutorial will demonstrate a manual installation using PHP + MySQL + Nginx. The official documentation also provides one-click installation scripts and Docker setups for those who prefer such installation methods.

Create a Database

Log in to the database:

mysql -uroot -p

Create a database:

CREATE DATABASE bookstack CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Install BookStack

Get the program source code:

git clone https://github.com/BookStackApp/BookStack.git --branch release --single-branch

Install Composer:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Set global access to Composer:

sudo mv composer.phar /usr/local/bin/composer

Navigate to the folder and install dependencies:

cd BookStack
composer install --no-dev

Modify the configuration file:

cp .env.example .env
vim .env

Here's a brief introduction to some commonly used parameters; for specific configurable parameters, please refer to the official documentation:

  • APP_KEY can be generated using the following command:

    • php artisan key:generate
  • APP_URL should be set to your site's domain.
  • APP_TIMEZONE should be set to the timezone used by your site, defaulting to UTC (Coordinated Universal Time).
  • DB_HOST, DB_DATABASE, DB_USERNAME, DB_PASSWORD are database-related information. If the database is on the local machine, DB_HOST should be set to localhost or 127.0.0.1.
  • MAIL_* related parameters can be configured for email notifications (e.g., email verification during registration, comment reply notifications, etc.).

Note: You can comment out unused parameters.

Update the database:

php artisan migrate

Configure Web Service

You can choose any web server, but PHP must allows to access parent directory, or errors may occur.

Here's an example of an Nginx configuration file:

server
    {   
        listen 80;
        listen 443 ssl;
        server_name bookstack.example.com;
        ssl_certificate ../your_ssl_cert.pem;
        ssl_certificate_key ../your_ssl_key.key;
        client_max_body_size 10M;
    
        root /your/bookstack/home/folder/public;
        index index.php index.html;

        include enable-php.conf;

        location / { 
            try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
            fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\. 
        {
            deny all;
        }

        access_log /path/to/your/logs.log;

    }   

Configuration

File Storage

BookStack currently supports four types of file storage:

  • Local storage (default)
  • Secure local storage
  • Restricted secure local storage
  • S3 storage

For detailed information about file storage, the official documentation provides comprehensive explanations. For more information, please refer to it.

TOC