Skip to main content

Bookstack

Setting Up BookStack

BookStack is a simple, self-hosted, easy-to-use platform for organizing and storing information.

1. Creating the LXC Container

  1. Create a new Debian Bookworm LXC container on your Proxmox VE host.
    • Allocate sufficient resources to the container (e.g., 2 CPU cores, 2 GB RAM, 20 GB storage).

2. Installing Dependencies

  1. Log in to the LXC container's shell.

  2. Install PHP, MariaDB, Git, and Apache:

    apt update
    apt install -y php8.2 php8.2-{curl,gd,mbstring,bcmath,mysql,xml,zip,ldap} mariadb-server git apache2
    
  3. Install Composer:

    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }"
    php composer-setup.php
    php -r "unlink('composer-setup.php');"
    mv composer.phar /usr/local/bin/composer
    

3. Setting Up BookStack

  1. Clone the BookStack repository:

    git clone https://github.com/BookStackApp/BookStack.git --branch release --single-branch /var/www/bookstack
    
  2. Install BookStack's PHP dependencies:

    cd /var/www/bookstack
    composer install --no-dev
    
  3. Create a .env file and generate an application key:

    cp .env.example .env
    php artisan key:generate
    

4. Configuring the Database

  1. Create a new database and user for BookStack:

    mysql -u root
    CREATE DATABASE books;
    CREATE USER 'books_admin'@'localhost' IDENTIFIED BY 'your-strong-password';
    GRANT ALL PRIVILEGES ON books.* TO 'books_admin'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
    
  2. Edit the .env file with your database details:

    # Database details
    DB_HOST=localhost
    DB_DATABASE=bookstack
    DB_USERNAME=bookstack
    DB_PASSWORD=your-strong-password
    
  3. Run the database migrations:

    php artisan migrate
    

5. Configuring Apache

  1. Edit the default Apache virtual host file at /etc/apache2/sites-available/000-default.conf with the following content:

    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/bookstack/public
    
        <Directory /var/www/bookstack/public/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    
  2. Enable the Apache rewrite module and restart Apache:

    a2enmod rewrite
    systemctl restart apache2
    
  3. Set the correct permissions for the BookStack directory:

    chown -R www-data:www-data /var/www/bookstack
    

6. Configuring LDAP Authentication

  1. Edit the .env file with your LDAP details:

    # General auth
    AUTH_METHOD=ldap
    
    # LDAP Details
    LDAP_SERVER=ldaps://dc1.yourdomain.com:636
    LDAP_BASE_DN="OU=Users,DC=yourdomain,DC=com"
    LDAP_DN="CN=bookstack,OU=ServiceAccounts,DC=yourdomain,DC=com"
    LDAP_PASS='your-bookstack-password'
    LDAP_USER_FILTER="(&(sAMAccountName={user})(memberOf=CN=BookStackUsers,OU=Groups,DC=yourdomain,DC=com))"
    LDAP_VERSION=3
    LDAP_ID_ATTRIBUTE=sAMAccountName
    LDAP_EMAIL_ATTRIBUTE=mail
    LDAP_DISPLAY_NAME_ATTRIBUTE=displayName
    LDAP_TLS_CA_CERT=/path/to/domain/ca_certs.pem
    

    [!IMPORTANT] You will need to create a books_admin service account and a BookStackUsers group in your Active Directory.

  2. Set the application URL in the .env file:

    APP_URL=http://books.yourdomain.com
    

You should now be able to log in to BookStack at http://books.yourdomain.com with your LDAP credentials.

[!WARNING] To set an admin user, you will need to log in with the default admin@admin.com:password credentials and promote one of your LDAP users to an admin role.