How to Install BookStack on Debian Latest

BookStack is an open-source platform to create documentation and wiki content in a simple and easy-to-use interface. In this tutorial, we will learn how to install BookStack on Debian latest.

1. Update and Upgrade Packages

Before installing any new package, it is recommended to update and upgrade existing packages to their latest available versions.

sudo apt update
sudo apt upgrade

2. Install Apache, PHP and Required Extensions

BookStack is a PHP and Apache based application, so we need to install them along with some required extensions.

sudo apt install apache2 php libapache2-mod-php php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-ldap php-zip php-curl

3. Install Required Dependencies

BookStack requires some external dependencies to work properly, run the following command to install them.

sudo apt install git curl libxrender1 libxext6 libfontconfig1 libjpeg62-turbo-dev libpng-dev libfreetype6-dev libzip-dev

4. Install and Setup MariaDB

MariaDB is a drop-in replacement for MySQL, which can be used to store data. Install and setup MariaDB by running the following command.

sudo apt install mariadb-server
sudo mysql_secure_installation

During the installation, you will be asked a few questions, such as setting the root password and removing anonymous users.

Create a new database and user for BookStack and grant all the necessary permissions.

sudo mysql -u root -p

MariaDB [(none)]> CREATE DATABASE bookstack;
MariaDB [(none)]> GRANT ALL ON bookstack.* TO 'bsuser'@'localhost' IDENTIFIED BY 'your-password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;

5. Install Composer

Composer is a dependency manager for PHP, used to manage dependencies of PHP applications like BookStack. Install Composer using the following command.

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

6. Clone and Configure BookStack

We will clone the latest version of BookStack from the official git repository in the /var/www directory.

sudo git clone https://github.com/BookStackApp/BookStack.git /var/www/BookStack

Navigate to the cloned directory.

cd /var/www/BookStack

Install the required dependencies using Composer.

sudo composer install --no-dev

Copy the environment file and generate the application key.

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

Update the .env file with the required database configuration.

sudo nano .env
DB_DATABASE=bookstack
DB_USERNAME=bsuser
DB_PASSWORD=your-password

Run the following command to migrate the database.

sudo php artisan migrate --seed

7. Configure Apache for BookStack

Create a new virtual host configuration file for BookStack.

sudo nano /etc/apache2/sites-available/bookstack.conf

Add the following content to the file.

<VirtualHost *:80>
    ServerName yourbookstack.local #Replace with your domain
    DocumentRoot /var/www/BookStack/public

    <Directory /var/www/BookStack/public>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/bookstack_error.log
    CustomLog ${APACHE_LOG_DIR}/bookstack_access.log combined
</VirtualHost>

8. Enable Required Apache Modules

Enable rewrite and headers Apache modules, used by BookStack.

sudo a2enmod rewrite headers

9. Change Ownership and Permission

Set the appropriate ownership and permission for the BookStack directory.

sudo chown -R www-data:www-data /var/www/BookStack
sudo chmod -R 755 /var/www/BookStack

10. Restart Apache and Test

Finally, restart the Apache service and open your browser to test the BookStack installation.

sudo systemctl restart apache2

http://yourbookstack.local/ #Replace with your domain

You should now see BookStack login page. To log in, use the following credentials:

Email: admin@admin.com
Password: password

In this tutorial, we have learned how to install BookStack on Debian Latest. You can now use BookStack to create beautiful and easy-to-use documentation.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!