Installing BookStack
This chapter installs BookStack the manual way, in the open, so you can see what the official install script does on your behalf. If you are putting BookStack on a fresh Ubuntu server and would rather not see the moving parts, the project's script is a legitimate choice — it installs Apache, MySQL and PHP, then performs the same steps below. The lab for this guide did it by hand so that every step could be verified, and because a by-hand install is the one you can repair later.
The target throughout is a small Linux server or virtual machine you control. Nothing here needs much power: a wiki for a household or a club runs happily on the smallest machine you have.
The requirements
From the project's installation documentation:
- PHP 8.2 or newer, with these extensions: curl, dom, gd, iconv, mbstring, mysqlnd, openssl, pdo, pdo_mysql, tokenizer, xml, zip. (ldap and exif are optional, for directory logins and for correct rotation of uploaded photos.)
- MySQL 8.0 or newer, or MariaDB 10.6 or newer, with a database and a user for BookStack's own use.
- Composer 2.2 or newer, the PHP dependency manager.
- Git, to fetch the code.
Check what you have before you start:
php --version
mysql --version # or: mariadb --version
composer --version
Step 1: the database
BookStack gets a database and a user of its own — never the root account:
CREATE DATABASE bookstack;
CREATE USER 'bookstack'@'localhost'
IDENTIFIED BY 'a-long-random-password';
GRANT ALL ON bookstack.* TO 'bookstack'@'localhost';
Check: from the shell,
mysql -u bookstack -p bookstack should
connect you. If it does not, stop here;
nothing later will work until it does.
Step 2: the code
cd /var/www
git clone https://source.bookstackapp.com/bookstack.git \
--branch release --single-branch bookstack
cd bookstack
composer install --no-dev
The clone takes the current stable
release. composer install fetches the
PHP libraries BookStack is built on; it
takes a few minutes and is the step most
likely to complain about a missing PHP
extension. The complaint names the
extension — install it and run the command
again.
Step 3: the settings file
cp .env.example .env
Edit .env and set at least these:
APP_URL=http://your-server-address
DB_HOST=localhost
DB_DATABASE=bookstack
DB_USERNAME=bookstack
DB_PASSWORD=a-long-random-password
APP_URL must be the address readers will
actually use, exactly — BookStack builds
links from it. Then generate the
application key:
php artisan key:generate --force
The --force matters more than it looks.
In a production install the command asks
"are you sure?" first, and a scripted or
piped run that can't answer simply cancels
in silence, leaving the placeholder key in
place. The lab hit exactly this: the fresh
install answered every page with a generic
"An unknown error occurred" until the log
gave the real reason — an invalid key.
Since v26.09 a valid APP_KEY is
mandatory, not a nicety. Chapter 14 has
the full story; for now, run the command,
then check:
grep APP_KEY .env
Check: the line shows a long generated
value (base64:...), not a placeholder.
Step 4: the tables, and first boot
php artisan migrate
Check: the command lists each migration running, and the database now holds a few dozen tables (41 in the lab's v26.09.2 install). Finally, give the web server ownership of the folders it must write:
chown -R www-data:www-data \
storage bootstrap/cache public/uploads
With Apache or Nginx configured to serve
the public folder, you are done: visit
the address and chapter 4 takes over.
The lab's declared deviations
Two, both deliberate, neither hidden:
- The web server. The lab served
BookStack with PHP's built-in
development server
(
php artisan serve) instead of Apache or Nginx. That proves the application, the database, and every workflow in this guide. It does not prove a production web-server configuration, and nobody should leave the development server facing a network they care about. - MariaDB instead of MySQL. Both are supported; the lab used MariaDB 10.11. Nothing in the guide's workflows behaved differently for it.
The install script itself was not run: a sandbox that already has an operating system on it is not the fresh machine the script expects, and the manual path is what the script automates.