BookStack is a simple, free, open-source, Laravel-based, wiki software organized into a hierarchy of bookshelfs, books, chapters, and pages. Check out their website and demo to learn more. Though installation on shared hosting is not currently recommended by the developers, it is certainly possible and works well in my experience. With just a few extra steps you’ll be filling those BookStack shelves in no time.
For the most part we’ll be following the “Manual Installation” section of their documentation and making some adjustments along the way.
Let’s get started, shall we?
Prerequisites
As of BookStack v0.27.5 (the version this tutorial is based on), we’ll need to meet the following requirements:
- cPanel Login & SSH Access
- I’ll be using the PuTTY SSH client for this tutorial.
- PHP >= 7.0.5
- For installation and maintenance, you’ll need to be able to run
php
from the command line. - Required Extensions: OpenSSL, PDO, MBstring, Tokenizer, GD, MySQL, Tidy, SimpleXML & DOM
- For installation and maintenance, you’ll need to be able to run
- MySQL >= 5.6
- Git Version Control
- For installation you’ll need to be able to run
git
from the command line.
- For installation you’ll need to be able to run
- Composer
- For installation you’ll need to be able to run
composer
from the command line.
- For installation you’ll need to be able to run
Installation
- Log in to your cPanel account.
- Use the MySQL Database Wizard to create a database and database user with all privileges to the database you’ve created. Take note of the full database name and user credentials for a later step.
- SSH into your cPanel server using your login credentials.
- Make sure you are in your home directory by running
cd ~
- Clone the release branch of the BookStack GitHub repository by running
git clone https://github.com/BookStackApp/BookStack.git --branch release --single-branch
. It will create aBookStack
directory for you automatically. - Run
cd BookStack
to get into the application folder and then runcomposer install
. It will take a few minutes to download all of the required packages. - Run
cp .env.example .env
to start your environment configuration file. - Run
php artisan key:generate
and confirm with a “yes” to generate a unique application key. This automatically updates theAPP_KEY
constant in your.env
file. - Run
nano .env
and fill it with your database details from step 2; set theAPP_URL
to the expected full public-facing URL of your BookStack site; set your mail details; save and exit the editor.- Example
.env
file:APP_KEY=base64:ip93b4kVjnVZdDYPdW+leQQHHHPFM2yrqMZGhhn8hfc= APP_URL=https://www.howto.casa/bookstack DB_HOST=localhost DB_DATABASE=howto_bkstack DB_USERNAME=howto_bkstack DB_PASSWORD=ka$js08h3*2x MAIL_DRIVER=mail
- Example
- Run
php artisan migrate
and confirm with a “yes” to prepare the database. - Run
chmod u+w ~/BookStack/storage ~/BookStack/bootstrap/cache
to ensure these folders are writable by the web server. - Ensure you are still in the
~/BookStack
directory, then move the contents of thepublic
folder into your~/public_html
directory or a sub-directory underneath if you are adding BookStack to an existing website. In our case we will runmkdir ~/public_html/bookstack
andmv public/* public/.htaccess ~/public_html/bookstack
to move them to~/public_html/bookstack
for a sub-directory installation. - Run
chmod u+w ~/public_html/bookstack/uploads
to ensure the folder is writable by the web server. - Change to your public installation directory, in our case we’ll run
cd ~/public_html/bookstack
. - Run
nano .htaccess
and addRewriteBase /bookstack/
on a line immediately belowRewriteEngine On
.- Note: If you are not installing into a sub-directory use
RewriteBase /
.
- Note: If you are not installing into a sub-directory use
- Run
nano index.php
and make the following changes:- On or around line 22 replace
require __DIR__.'/../bootstrap/init.php';
withrequire realpath($_SERVER['DOCUMENT_ROOT'].'/..').'/BookStack/bootstrap/init.php';
. - On or around line 36 replace
$app = require_once __DIR__.'/../bootstrap/app.php';
with$app = require_once realpath($_SERVER['DOCUMENT_ROOT'].'/..').'/BookStack/bootstrap/app.php';
and immediately afterwards add the following line:
$app->bind('path.public', function() { return __DIR__; });
- On or around line 22 replace
- Done! You can now navigate to your public-facing BookStack URL and login using the default admin details,
admin@admin.com
with a password ofpassword
. For security reasons, change these details immediately after logging in for the first time.
Joey says
Thanks for posting this, I’ve been trying to figure out how to do this using the the hosting I already have. I think it’s a bit over my head though, and without a video to follow along, it’s hard for me. I think I’m going to try to do it with digital ocean, as it’s not shared and it’s a little more straightforward. Maybe I’ll just eventually migrate the whole site there. But thanks for the careful instructions.
Bridges says
Wonderful Explanation.
Sam says
Hi
I really need to know how I can bring bookstack up running on a hosted webserver.
I don’t have php console or composer and only limited ssh 🙁
Is it possible to prepare everything locally and then upload the folders/files and import the local exported sql?
KR Sam
Josh Hartman says
Theoretically yes, but having not tested it I can’t guarantee that would work and even if it does it would make updating difficult. You would be better off with a web host that gives you more flexibility. I think you already know that.