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?
UPDATE (3/29/2024): This method still works, tested with BookStack v24.02.2, however make sure you are running PHP 8.0.2 or greater for both web and CLI.
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
phpfrom 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
gitfrom the command line.
- For installation you’ll need to be able to run
- Composer
- For installation you’ll need to be able to run
composerfrom 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 aBookStackdirectory for you automatically. - Run
cd BookStackto 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 .envto start your environment configuration file. - Run
php artisan key:generateand confirm with a “yes” to generate a unique application key. This automatically updates theAPP_KEYconstant in your.envfile. - Run
nano .envand fill it with your database details from step 2; set theAPP_URLto the expected full public-facing URL of your BookStack site; set your mail details; save and exit the editor.- Example
.envfile: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 migrateand confirm with a “yes” to prepare the database. - Run
chmod u+w ~/BookStack/storage ~/BookStack/bootstrap/cacheto ensure these folders are writable by the web server. - Ensure you are still in the
~/BookStackdirectory, then move the contents of thepublicfolder into your~/public_htmldirectory or a sub-directory underneath if you are adding BookStack to an existing website. In our case we will runmkdir ~/public_html/bookstackandmv public/* public/.htaccess ~/public_html/bookstackto move them to~/public_html/bookstackfor a sub-directory installation. - Run
chmod u+w ~/public_html/bookstack/uploadsto 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 .htaccessand 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.phpand 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.comwith a password ofpassword. For security reasons, change these details immediately after logging in for the first time.
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.
Wonderful Explanation.
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
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.