Bookstack: Difference between revisions
Delete section pointing to removed option, see https://github.com/NixOS/nixpkgs/blame/26.05/nixos/modules/services/web-apps/bookstack.nix#L139 |
|||
| (One intermediate revision by one other user not shown) | |||
| Line 7: | Line 7: | ||
== Configuration == | == Configuration == | ||
BookStack | BookStack requires some configuration to get working. You'll need to set up a secret and a database to connect to. | ||
=== App secret === | |||
BookStack requires an app secret, primarily used for encryption. You can generate a valid app key using the following command:<syntaxhighlight lang="bash"> | |||
echo base64:$(nix run nixpkgs#openssl -- rand -base64 32) | echo base64:$(nix run nixpkgs#openssl -- rand -base64 32) | ||
</syntaxhighlight>Write this value to a file owned by the <code>bookstack</code> user in the <code>bookstack</code> group, perhaps using a secret manager such as [[Agenix]], and provide its path to Bookstack:<syntaxhighlight lang="nixos"> | </syntaxhighlight>Write this value to a file owned by the <code>bookstack</code> user in the <code>bookstack</code> group, perhaps using a secret manager such as [[Agenix]], and provide its path to Bookstack:<syntaxhighlight lang="nixos"> | ||
services.bookstack. | services.bookstack.settings.APP_KEY_FILE = "path-to-your-secret"; | ||
</syntaxhighlight>And using [[Agenix]],<syntaxhighlight lang="nixos"> | </syntaxhighlight>And using [[Agenix]],<syntaxhighlight lang="nixos"> | ||
services.bookstack. | services.bookstack.settings.APP_KEY_FILE = config.age.secrets.bookstack-appkey.path; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Database === | |||
BookStack uses a MySQL (MariaDB) as a DBMS. Connection parameters are provided via <code>services.bookstack.settings</code>. To point at a database running locally, your configuration might look like this:<syntaxhighlight lang="nixos"> | |||
services.bookstack.settings.DB_HOST = "localhost"; | |||
services.bookstack.settings.DB_PORT = 3306; | |||
services.bookstack.settings.DB_USERNAME = "bookstack"; | |||
services.bookstack.settings.DB_DATABASE = "bookstack"; | |||
services.bookstack.settings.DB_SOCKET = "/run/mysqld/mysqld.sock"; | |||
</syntaxhighlight>A locally-running database can be be configured with the following:<syntaxhighlight lang="nixos"> | |||
services.mysql = { | |||
enable = true; | |||
package = pkgs.mariadb; | |||
settings.mysqld.character-set-server = "utf8mb4"; | |||
ensureDatabases = [ "bookstack" ]; | |||
ensureUsers = [{ | |||
name = "bookstack"; | |||
ensurePermissions = { | |||
"bookstack.*" = "ALL PRIVILEGES"; | |||
}; | |||
}]; | |||
}; | |||
</syntaxhighlight> | |||
=== Serving === | |||
BookStack needs to know the domain on which it runs and the URL used to access it:<syntaxhighlight lang="nixos"> | |||
services.bookstack.hostname = "kb.example.com"; | |||
services.bookstack.settings.APP_URL = "http://kb.example.com"; | |||
</syntaxhighlight>To go further, it is useful to know that BookStack uses Laravel. So, for example, to use S3 instead of the local filesystem, check Laravel's documentation on file storage and the service definition. | |||
== Tips and tricks == | == Tips and tricks == | ||
| Line 35: | Line 62: | ||
== Troubleshooting == | == Troubleshooting == | ||
=== " | === "An unknown error occurred" when viewing your wiki in a browser === | ||
If you set up BookStack with NixOS < 25.11, you might have used an un-prefixed base64-encoded app key. Make sure your app key file contents include the "base64:" prefix. | |||
=== Logs locations === | |||
With the default settings, BookStack logs can be found under <code>/var/lib/bookstack/storage/logs/</code>. | |||
[[Category:Server]] | [[Category:Server]] | ||
[[Category:Web Applications]] | [[Category:Web Applications]] | ||
Latest revision as of 11:52, 14 August 2026
BookStack is a platform for organising and storing information.
Installation
To install BookStack, add the following to your NixOS configuration:
services.bookstack.enable = true;
More options are available.
Configuration
BookStack requires some configuration to get working. You'll need to set up a secret and a database to connect to.
App secret
BookStack requires an app secret, primarily used for encryption. You can generate a valid app key using the following command:
echo base64:$(nix run nixpkgs#openssl -- rand -base64 32)
Write this value to a file owned by the bookstack user in the bookstack group, perhaps using a secret manager such as Agenix, and provide its path to Bookstack:
services.bookstack.settings.APP_KEY_FILE = "path-to-your-secret";
And using Agenix,
services.bookstack.settings.APP_KEY_FILE = config.age.secrets.bookstack-appkey.path;
Database
BookStack uses a MySQL (MariaDB) as a DBMS. Connection parameters are provided via services.bookstack.settings. To point at a database running locally, your configuration might look like this:
services.bookstack.settings.DB_HOST = "localhost";
services.bookstack.settings.DB_PORT = 3306;
services.bookstack.settings.DB_USERNAME = "bookstack";
services.bookstack.settings.DB_DATABASE = "bookstack";
services.bookstack.settings.DB_SOCKET = "/run/mysqld/mysqld.sock";
A locally-running database can be be configured with the following:
services.mysql = {
enable = true;
package = pkgs.mariadb;
settings.mysqld.character-set-server = "utf8mb4";
ensureDatabases = [ "bookstack" ];
ensureUsers = [{
name = "bookstack";
ensurePermissions = {
"bookstack.*" = "ALL PRIVILEGES";
};
}];
};
Serving
BookStack needs to know the domain on which it runs and the URL used to access it:
services.bookstack.hostname = "kb.example.com";
services.bookstack.settings.APP_URL = "http://kb.example.com";
To go further, it is useful to know that BookStack uses Laravel. So, for example, to use S3 instead of the local filesystem, check Laravel's documentation on file storage and the service definition.
Tips and tricks
Changing the default port Nginx listens on
services.bookstack.nginx.listen = [
{ addr = "[::]"; port = 8080; ssl = false;}
{ addr = "0.0.0.0"; port = 8080; ssl = false;}
{ addr = "[::]"; port = 8443; ssl = true;}
{ addr = "0.0.0.0"; port = 8443; ssl = true;}
]
Troubleshooting
"An unknown error occurred" when viewing your wiki in a browser
If you set up BookStack with NixOS < 25.11, you might have used an un-prefixed base64-encoded app key. Make sure your app key file contents include the "base64:" prefix.
Logs locations
With the default settings, BookStack logs can be found under /var/lib/bookstack/storage/logs/.