Table of Contents

Bookstack

Ébauche

Ne pas prendre cette procédure pour exemple. Elle m'a servie dans un environnement de test, pas en prod !

Pré-requis

Installer les paquets nécéssaires

apt install -y apache2 php php-{gd,mbstring,tokenizer,xml,curl,mysql} libapache2-mod-php mariadb-server mariadb-client git unzip

Activer les services

Activer les services

systemctl enable apache2
a2enmod "php*" rewrite
sysemctl restart apache2

Paramétrer Mariadb

Configurer MariaDB :

mysql_secure_installation
 
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
 
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
 
Enter current password for root (enter for none):
OK, successfully used password, moving on...
 
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
 
You already have your root account protected, so you can safely answer 'n'.
 
Switch to unix_socket authentication [Y/n] n
 ... skipping.
 
You already have your root account protected, so you can safely answer 'n'.
 
Change the root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!
 
 
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
 
Remove anonymous users? [Y/n] y
 ... Success!
 
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
 
Disallow root login remotely? [Y/n] y
 ... Success!
 
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
 
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
 
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
 
Reload privilege tables now? [Y/n] y
 ... Success!
 
Cleaning up...
 
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
 
Thanks for using MariaDB!

On créé la base :

mysql -u root -p
CREATE DATABASE bookstack;
CREATE USER 'bookadm'@'localhost' IDENTIFIED BY 'motdepassedelamort';
GRANT ALL ON bookstack.* TO 'bookadm'@'localhost'; 

Installer Composer

Installer Composer. On va l'installer globalement parce je ne sais pas ce que je fais.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
 
mv composer.phar /usr/local/bin/composer
composer

Installer BookStack

Récupérer BookStack

cd /var/www
git clone https://github.com/BookStackApp/BookStack.git --branch release --single-branch
mv BookStack bookstack
cd bookstack
composer install --no-dev
cp .env.example .env

On continue les trucs de BookStack

php artisan key:generate
Sélectionner Yes

On édite le .env

.env
APP_URL=https://bookstack.domaine.tld
 
DB_HOST=localhost
DB_DATABASE=bookstack
DB_USERNAME=root
DB_PASSWORD=mot de passe BDD

On bidouille les droits

chown -R www-data:www-data /var/www/bookstack
chmod -R 755 /var/www/bookstack
chmod -R 775 /var/www/bookstack/storage /var/www/bookstack/bootstrap/cache /var/www/bookstack/public/uploads
chmod 640 /var/www/bookstack/.env

Et on migre la base

php artisan migrate

Préparation vu vHost Apache

On créé le vHost Apache

nano /etc/apache2/site-available/bookstack.conf

Et on va honteusement piller le modèle fourni par BookStack :

bookstack.conf
<VirtualHost *:80>
 
	# This is a simple example of an Apache VirtualHost configuration
	# file that could be used with BookStack.
	# This assumes mod_php has been installed and is loaded.
	#
	# Change the "docs.example.com" usage in the "ServerName" directive
	# to be your web domain for BookStack.
	#
	# Change the "/var/www/bookstack/public/", used twice below, to the
	# location of the "public" folder within your BookStack installation.
	#
	# This configuration is only for HTTP, Not HTTPS.
	# For HTTPS we recommend using https://certbot.eff.org/
 
	ServerName docs.example.com
	DocumentRoot /var/www/bookstack/public/
 
	<Directory /var/www/bookstack/public/>
		Options Indexes FollowSymLinks
		AllowOverride None
		Require all granted
		<IfModule mod_rewrite.c>
			<IfModule mod_negotiation.c>
				Options -MultiViews -Indexes
			</IfModule>
 
			RewriteEngine On
 
			# Handle Authorization Header
			RewriteCond %{HTTP:Authorization} .
			RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
 
			# Redirect Trailing Slashes If Not A Folder...
			RewriteCond %{REQUEST_FILENAME} !-d
			RewriteCond %{REQUEST_URI} (.+)/$
			RewriteRule ^ %1 [L,R=301]
 
			# Handle Front Controller...
			RewriteCond %{REQUEST_FILENAME} !-d
			RewriteCond %{REQUEST_FILENAME} !-f
			RewriteRule ^ index.php [L]
		</IfModule>
	</Directory>
 
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

On active le vHost

a2ensite bookstack.conf
systemctl reload apache2

Profit

Normalement tout est bon. Il reste à se connecter les identifiants par défaut :