BookStack is a powerful and versatile wiki software that allows businesses to store and organize information effectively. If you’re looking to set up your own wiki-like platform using BookStack on a Debian 12 server, you’re in the right place. In this guide, we will walk you through the step-by-step installation process, ensuring that you have a fully functional BookStack instance up and running in no time.
Before we dive into the installation process, let’s go over the prerequisites to ensure that you have everything you need:
Prerequisites
- A Debian 12 server
- A non-root user with sudo administrator privileges
- A domain name pointed to the server IP address
Now that you have the necessary prerequisites in place, let’s move on to installing the dependencies required for BookStack.
Installing Dependencies
BookStack is built with PHP and utilizes MySQL/MariaDB for the database. To get started, we need to install the LAMP stack (Apache2, MariaDB, PHP), Git, and Composer. Execute the following commands on your Debian 12 server:
sudo apt update sudo apt install apache2 mariadb-server composer curl php php-xml libapache2-mod-php php-fpm php-curl php-mbstring php-ldap php-tidy php-zip php-gd php-mysql git
During the installation, you’ll be prompted to confirm the installation of the packages. Type ‘y’ and hit Enter to proceed.
Once the dependencies are installed, let’s ensure that each component is functioning correctly. Run the following commands to verify the status of Apache2, MariaDB, PHP, and Composer:
sudo systemctl status apache2 sudo systemctl status mariadb php -v composer -v
These commands will display the status and version information for each component, confirming that they are installed and running properly.
With the dependencies in place, we can now proceed to configure PHP on your Debian machine.
Configuring PHP
To optimize PHP for BookStack, we need to make some changes to the php.ini
file. Open the file using a text editor of your choice. In this example, we’ll use nano:
sudo nano /etc/php/8.2/apache2/php.ini
Within the file, locate the date.timezone
and memory_limit
parameters. Adjust them as needed to match your server environment. For example:
date.timezone = Europe/Amsterdam memory_limit = 512M
Save the changes and exit the editor.
To apply the new PHP configuration, restart the Apache2 service with the following command:
sudo systemctl restart apache2
Now that PHP is properly configured, let’s move on to setting up the MariaDB server.
Configuring MariaDB Server
To ensure the security of your MariaDB installation and create a database for BookStack, we’ll use the mariadb-secure-installation
utility. Run the following command to start the configuration process:
sudo mariadb-secure-installation
The utility will guide you through a series of prompts to secure your MariaDB installation. Here are the recommended configurations:
- When asked about the root password, press Enter for a default installation without a root password.
- When prompted to change the authentication method to
unix_socket
, enter ‘n’. - Create a new MariaDB root password and confirm it.
- Disable remote authentication for the MariaDB root user by entering ‘Y’.
- Remove the default
test
database and anonymous privileges by entering ‘Y’. - Confirm table privileges reloading by entering ‘Y’.
With MariaDB secured, we can create a new database and user specifically for BookStack. Access the MariaDB server with the following command:
sudo mariadb -u root -p
Enter your MariaDB root password when prompted.
Once inside the MariaDB server, execute the following queries to create the BookStack database and user:
CREATE DATABASE bookstack; CREATE USER bookstack@localhost IDENTIFIED BY 'p4ssword'; GRANT ALL ON bookstack.* TO bookstack@localhost WITH GRANT OPTION; FLUSH PRIVILEGES;
To confirm that the privileges for the new user have been set correctly, run the following query:
SHOW GRANTS FOR bookstack@localhost;
You should see the privileges listed, indicating that the user is allowed to access and manage the BookStack database.
Exit the MariaDB server by entering quit
.
Now that the database is set up, let’s proceed to the next step: downloading and installing BookStack.
Downloading BookStack
We’ll be using Git and Composer to download and install BookStack. Before we begin, let’s create a couple of directories and set the appropriate permissions. Run the following commands:
sudo mkdir -p /var/www/.config/var/www/.cache sudo chown -R www-data /var/www/{.config,.cache}
These directories will be used by Composer to store dependencies cache and configuration. The www-data
user should have ownership of these directories.
Navigate to the /var/www
directory and clone the BookStack repository:
cd /var/www sudo git clone https://github.com/BookStackApp/BookStack.git --branch release --single-branch bookstack
Adjust the ownership of the bookstack
directory:
sudo chown -R www-data:www-data /var/www/bookstack cd /var/www/bookstack
Copy the example .env
file and open it for editing:
sudo -u www-data cp.env.example.env sudo -u www-data nano.env
Within the .env
file, update the APP_URL
option with your domain name and set the appropriate values for the DB_DATABASE
,DB_USERNAME
, and DB_PASSWORD
options. For example:
APP_URL=http://bookstack.example.com DB_DATABASE=bookstack DB_USERNAME=bookstack DB_PASSWORD=p4ssword
Save the changes and exit the editor.
Now, let’s install the PHP dependencies using Composer:
sudo -u www-data composer install --no-dev --no-plugins
This command will download and install the required PHP dependencies for BookStack.
After the dependencies are installed, generate the secret key and migrate the database:
sudo -u www-data php artisan key:generate --no-interaction --force sudo -u www-data php artisan migrate --no-interaction --force
These commands will generate a secret key for BookStack and set up the necessary database tables.
To ensure the proper functioning of BookStack, adjust the ownership and permissions of certain directories:
sudo chown www-data:www-data -R bootstrap/cachepublic/uploads storage sudo chmod u+rw bootstrap/cachepublic/uploads storage
Finally, restrict access to the .env
file to the www-data
user:
sudo chmod 640 /var/www/bookstack/.env
With BookStack installed and configured, let’s move on to setting up the Apache2 virtual host.
Configuring Apache2 Virtual Host
To run BookStack on Apache2, we need to create a virtual host configuration file. First, enable the Apache2 rewrite module:
sudo a2enmod rewrite
Now, create a new virtual host configuration file:
sudo nano /etc/apache2/sites-available/bookstack.conf
Within the file, add the following configuration, replacing bookstack.example.com
with your domain name:
<VirtualHost *:80> ServerName bookstack.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/bookstack/public/ <Directory /var/www/bookstack/public/> Options Indexes FollowSymLinks AllowOverride None Require all granted <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> </Directory> ErrorLog ${APACHE_LOG_DIR}/bookstack-error.log CustomLog ${APACHE_LOG_DIR}/bookstack-access.log combined </VirtualHost>
Save the file and exit the editor.
Enable the virtual host configuration and verify the Apache2 syntax:
sudo a2ensite bookstack.conf
sudo apachectl configtest
If the syntax is correct, you will see “Syntax OK” displayed in the output.
Finally, restart the Apache2 service to apply the changes:
sudo systemctl restart apache2
Now that BookStack is secured with SSL/TLS certificates, it’s time to access and explore your new wiki platform.
Accessing BookStack
To access your BookStack installation, open a web browser and visit your domain name. For example, if your domain is bookstack.example.com
, enter https://bookstack.example.com
in the address bar.
You will be redirected to the BookStack login page. Use the default email address admin@example.com
and the password password
to log in.
If everything is set up correctly, you should now see the BookStack dashboard, ready for you to start creating and organizing your information.
Conclusion
Congratulations! You’ve successfully installed BookStack on your Debian 12 server. By following this comprehensive guide, you now have a fully functional wiki-like platform for storing and organizing information.
BookStack offers a wide range of features and customization options, allowing you to build a powerful knowledge base that meets your specific needs. Explore the various settings and configurations to tailor BookStack to your requirements.
If you’re looking for reliable and scalable cloud hosting solutions, consider Shape.host. Their Cloud VPS services provide excellent performance and security, ensuring that your BookStack installation runs smoothly and efficiently. Visit Shape.host to learn more about their hosting solutions and take your BookStack experience to the next level.