BookStack is an open-source, self-hosted platform for organizing and storing documentation. It offers a simple and user-friendly interface, making it a great choice for teams and individuals who need a wiki-style knowledge management system. This guide will show you how to install BookStack on Ubuntu, Debian, AlmaLinux, and Rocky Linux.
Prerequisites
Before installing BookStack, ensure you have the following:
-
A server running Ubuntu 22.04/20.04, Debian 11/10, AlmaLinux 9/8, or Rocky Linux 9/8.
-
Root or sudo access.
-
A LAMP or LEMP stack installed (Apache/Nginx, MySQL/MariaDB, PHP).
-
Git installed.
Step 1: Update Your System
Update your package lists and upgrade installed packages:
sudo apt update && sudo apt upgrade -y # For Ubuntu/Debian
sudo dnf update -y # For AlmaLinux/Rocky
Step 2: Install Required Packages
Install Apache/Nginx, MariaDB, PHP, and other dependencies:
# For Ubuntu/Debian
sudo apt install apache2 mariadb-server php php-cli php-mbstring php-xml php-curl php-zip unzip git composer -y
# For AlmaLinux/Rocky
sudo dnf install httpd mariadb-server php php-cli php-mbstring php-xml php-curl php-zip unzip git composer -y
Start and enable services:
sudo systemctl enable --now apache2 mariadb # Ubuntu/Debian
sudo systemctl enable --now httpd mariadb # AlmaLinux/Rocky
Step 3: Configure Database
Secure your MariaDB installation:
sudo mysql_secure_installation
Create a database and user for BookStack:
sudo mysql -u root -p
CREATE DATABASE bookstack;
CREATE USER 'bookstack_user'@'localhost' IDENTIFIED BY 'secure_password';
GRANT ALL PRIVILEGES ON bookstack.* TO 'bookstack_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 4: Download and Set Up BookStack
Navigate to the web root and clone BookStack:
cd /var/www/
sudo git clone https://github.com/BookStackApp/BookStack.git --branch release --single-branch bookstack
sudo mv bookstack /var/www/html/
Set correct permissions:
sudo chown -R www-data:www-data /var/www/html/bookstack
sudo chmod -R 755 /var/www/html/bookstack
Step 5: Configure Apache/Nginx
Apache Virtual Host Configuration
Create a new virtual host file:
sudo nano /etc/apache2/sites-available/bookstack.conf
Add the following content:
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/bookstack/public
ServerName your-domain.com
<Directory /var/www/html/bookstack/public>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the site and restart Apache:
sudo a2ensite bookstack.conf
sudo systemctl restart apache2
Nginx Configuration
Create a new Nginx configuration file:
sudo nano /etc/nginx/conf.d/bookstack.conf
Add the following content:
server {
listen 80;
server_name your-domain.com;
root /var/www/html/bookstack/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Restart Nginx:
sudo systemctl restart nginx
Step 6: Configure BookStack
Copy the environment file:
cd /var/www/html/bookstack
sudo cp .env.example .env
Update database details in .env
:
sudo nano .env
Set the following values:
DB_DATABASE=bookstack
DB_USERNAME=bookstack_user
DB_PASSWORD=secure_password
APP_URL=http://your-domain.com
Run the database migration:
sudo php artisan migrate --force
Set application key:
sudo php artisan key:generate
Restart the web server:
sudo systemctl restart apache2 # or nginx
Step 7: Finalize Installation
-
Open your browser and visit
http://your-domain.com
. -
Log in using the default credentials:
-
Email:
admin@admin.com
-
Password:
password
-
-
Change your password immediately.
Conclusion
You have successfully installed BookStack on Ubuntu, Debian, AlmaLinux, or Rocky Linux. Your documentation management tool is now ready to use. To enhance security, enable SSL with Let’s Encrypt and configure a firewall.