How to Install BookStack on Void Linux

BookStack is a platform for organizing and storing documentation, notes, and knowledge. In this tutorial, we will guide you through the steps to install BookStack on Void Linux.

Prerequisites

Before we begin, please ensure you have the following prerequisites:

Step 1: Update System Packages

The first step is to update the system packages on your server. Open the command line and run the following command:

sudo xbps-install -Suy

This will update all the system packages on your server.

Step 2: Install Required Packages

Next, we need to install the packages required for BookStack. Run the following command to install them:

sudo xbps-install -y git unzip nginx mariadb-server php php-fpm php-mysqli php-json php-gd

This will install Git, Unzip, Nginx, MariaDB Server, and PHP with required extensions.

Step 3: Prepare Database for BookStack

We need to create a new database and user for BookStack. To do this, run the following command:

sudo mysql -u root -p

This will prompt you for the MariaDB root password. Enter the password and log in to the MariaDB.

Next, run the following SQL commands to create a new database, user, and grant permissions:

CREATE DATABASE bookstack;
CREATE USER 'bookstack'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON bookstack.* TO 'bookstack'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Replace 'password' with a strong password for the BookStack user.

Step 4: Download and Configure BookStack

We will now download the latest version of BookStack from the official website. Run the following commands to download BookStack and extract the files:

cd /var/www/
sudo git clone https://github.com/BookStackApp/BookStack.git
sudo chown -R www-data:www-data /var/www/BookStack
sudo chmod -R 755 /var/www/BookStack/storage

Next, we need to copy the example configuration file and make necessary changes. Run the following commands:

sudo cp /var/www/BookStack/.env.example /var/www/BookStack/.env
sudo nano /var/www/BookStack/.env

In the .env file, find the lines which define the database connection values and change them to:

DB_DATABASE=bookstack
DB_USERNAME=bookstack
DB_PASSWORD=password

Save the changes and exit the editor.

Step 5: Configure Nginx

We need to configure Nginx to serve BookStack. Run the following command to open the Nginx configuration file:

sudo nano /etc/nginx/conf.d/default.conf

Replace the entire contents of the file with the following:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name example.com;
    root /var/www/BookStack/public;

    index index.php;
    charset utf-8;

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

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/run/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

Change 'example.com' with your own domain name.

Save the changes and exit the editor.

Now, test the configuration file and reload the Nginx service:

sudo nginx -t
sudo systemctl reload nginx

Step 6: Configure PHP-FPM

We need to make some changes to the PHP-FPM configuration file. Open the file using your favorite editor:

sudo nano /etc/php/php-fpm.d/www.conf

Find the line user = nginx and change it to user = www-data.

Find the line group = nginx and change it to group = www-data.

Save the changes and exit the editor.

Now, restart the PHP-FPM service to apply the changes:

sudo systemctl restart php-fpm

Step 7: Complete Installation using Web Installer

Open your web browser and navigate to http://example.com/install.

Replace 'example.com' with your own domain name.

Follow the on-screen instructions to complete the installation.

After installation, remove the install directory:

sudo rm -rf /var/www/BookStack/public/install

Conclusion

We have successfully installed BookStack on Void Linux. You can now start organizing and storing your documentation, notes or knowledge. If you face any issues, feel free to refer to the official documentation at https://docs.bookstackapp.com/.

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!