BookStack is a free and open-source wiki platform that allows users to create and organize content in a user-friendly way. It is built using PHP and Laravel framework which makes it highly customizable and easy to use.
In this tutorial, we will cover the steps required to install BookStack on the latest version of NixOS. Follow the steps below to get started:
Before installing BookStack, we need to ensure that all Nix packages are up to date. This can be done by running the following commands:
$ sudo nix-channel --update
$ sudo nix-env -iA nixpkgs.nix
We need to install Apache web server, PHP, and MySQL packages as these are the prerequisites needed to run BookStack. To install these packages, run the following commands:
$ sudo nix-env -iA nixpkgs.apacheHttpd
$ sudo nix-env -iA nixpkgs.php74
$ sudo nix-env -iA nixpkgs.mariadb
To install BookStack, follow the steps below:
$ sudo mkdir /var/www/bookstack
$ sudo chown www-data:www-data /var/www/bookstack
$ sudo chmod 775 /var/www/bookstack
$ sudo curl -s https://api.github.com/repos/BookStackApp/BookStack/releases/latest \
| grep "browser_download_url.*zip" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -O bookstack.zip -qi -
$ sudo unzip bookstack.zip -d /var/www/bookstack
$ sudo mv /var/www/bookstack/BookStack-* /var/www/bookstack/bookstack
$ sudo chown -R www-data:www-data /var/www/bookstack
BookStack needs to be configured with an Apache virtual host. To create the virtual host, follow the steps below:
bookstack.conf
in the /etc/apache2/vhosts.d/
directory:$ sudo nano /etc/apache2/vhosts.d/bookstack.conf
<VirtualHost *:80>
ServerName bookstack.example.com
ServerAlias www.bookstack.example.com
DocumentRoot /var/www/bookstack/bookstack/public
<Directory /var/www/bookstack/bookstack/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/bookstack_error.log
CustomLog /var/log/apache2/bookstack_access.log combined
</VirtualHost>
Note: Replace bookstack.example.com
and www.bookstack.example.com
with your domain name.
We need to create a database and user for BookStack. To create a new database and user, run the following commands:
$ sudo mysql -u root
mysql> CREATE DATABASE bookstack;
mysql> CREATE USER 'bookstack_user'@'localhost' IDENTIFIED BY 'password';
Note: Replace password
with your desired password.
mysql> GRANT ALL PRIVILEGES ON bookstack.* TO 'bookstack_user'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
We need to configure the BookStack environment file. To do this, run the following commands:
$ sudo cp /var/www/bookstack/bookstack/.env.example /var/www/bookstack/bookstack/.env
.env
file and edit the following line:APP_URL="http://bookstack.example.com"
Note: Replace bookstack.example.com
with your domain name.
DB_HOST=localhost
DB_DATABASE=bookstack
DB_USERNAME=bookstack_user
DB_PASSWORD=password
Note: Replace password
with your MySQL password.
We need to run the BookStack migrations to create the necessary database tables. To do this, run the following command:
$ php /var/www/bookstack/bookstack/artisan migrate
If you are running SELinux, you may need to grant Apache permissions to access the BookStack files. To do this, run the following command:
$ sudo chcon -R -t httpd_sys_rw_content_t /var/www/bookstack
To start Apache, run the following command:
$ sudo systemctl start apache2
BookStack is now installed and configured. Open your web browser and navigate to your BookStack domain name to start using BookStack.
Congratulations! You have successfully installed BookStack on NixOS.
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!