Skip to main content

Nouvelle page

Installation de BookStack sur Debian 13 (sans interface graphique)

Stack : Apache2 + PHP 8.4 + MariaDB + Composer, installation depuis le dépôt Git officiel (branche release).

Commandes à lancer en root (su -) ou avec sudo. Remplacer wiki.example.com par le domaine (ou l'IP du serveur) et MotDePasseSolide par un vrai mot de passe.

1. Mise à jour du système

apt update && apt full-upgrade -y
apt install -y curl git unzip ca-certificates

2. Installer Apache, PHP, MariaDB et Composer

apt install -y apache2 mariadb-server \
  php php-cli libapache2-mod-php \
  php-mysql php-curl php-mbstring php-xml php-zip php-gd php-ldap php-intl \
  composer

Vérification :

php -v
apache2 -v
mariadb --version
composer --version

3. Sécuriser MariaDB

mariadb-secure-installation

4. Créer la base de données

mariadb

Dans la console MariaDB :

CREATE DATABASE bookstack CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'bookstack'@'localhost' IDENTIFIED BY 'MotDePasseSolide';
GRANT ALL PRIVILEGES ON bookstack.* TO 'bookstack'@'localhost';
FLUSH PRIVILEGES;
EXIT;

5. Télécharger BookStack

cd /var/www
git clone https://github.com/BookStackApp/BookStack.git --branch release --single-branch bookstack
cd /var/www/bookstack

6. Installer les dépendances PHP

COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev

7. Configurer le fichier .env

cp .env.example .env
nano .env

Modifier ces lignes (APP_URL sans / à la fin) :

APP_URL=http://wiki.example.com

DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=bookstack
DB_USERNAME=bookstack
DB_PASSWORD=MotDePasseSolide

Générer la clé et créer les tables :

php artisan key:generate --force
php artisan migrate --force

8. Droits sur les fichiers

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

9. Configurer Apache

a2enmod rewrite
nano /etc/apache2/sites-available/bookstack.conf

Contenu du fichier :

<VirtualHost *:80>
    ServerName wiki.example.com
    ServerAdmin admin@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

            RewriteCond %{HTTP:Authorization} .
            RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_URI} (.+)/$
            RewriteRule ^ %1 [L,R=301]

            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [L]
        </IfModule>
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/bookstack_error.log
    CustomLog ${APACHE_LOG_DIR}/bookstack_access.log combined
</VirtualHost>

Activer le site :

a2ensite bookstack.conf
a2dissite 000-default.conf
apache2ctl configtest
systemctl reload apache2

10. Premier accès

Ouvrir http://wiki.example.com (ou http://IP_DU_SERVEUR).

  • Email : admin@admin.com
  • Mot de passe : password

À changer immédiatement dans Profil > Modifier le profil.

11. HTTPS avec Let's Encrypt (recommandé)

apt install -y certbot python3-certbot-apache
certbot --apache -d wiki.example.com

Passer ensuite APP_URL en https://wiki.example.com dans le .env :

nano /var/www/bookstack/.env
cd /var/www/bookstack
php artisan config:clear
systemctl reload apache2

12. Pare-feu (facultatif)

apt install -y ufw
ufw allow OpenSSH
ufw allow "WWW Full"
ufw enable

13. Mise à jour de BookStack

Faire une sauvegarde avant (section 14).

cd /var/www/bookstack
git pull origin release
COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev
php artisan migrate --force
php artisan cache:clear
php artisan config:clear
php artisan view:clear
chown -R www-data:www-data /var/www/bookstack

14. Sauvegarde et restauration

Sauvegarde :

mkdir -p /root/backups
mariadb-dump bookstack > /root/backups/bookstack-db-$(date +%F).sql
tar czf /root/backups/bookstack-files-$(date +%F).tar.gz -C /var/www/bookstack .env public/uploads storage/uploads

Restauration :

mariadb bookstack < /root/backups/bookstack-db-AAAA-MM-JJ.sql
tar xzf /root/backups/bookstack-files-AAAA-MM-JJ.tar.gz -C /var/www/bookstack
chown -R www-data:www-data /var/www/bookstack

15. Dépannage

Logs à consulter en cas d'erreur 500 ou de page blanche :

tail -f /var/log/apache2/bookstack_error.log
tail -f /var/www/bookstack/storage/logs/laravel.log
Problème Solution
404 partout sauf l'accueil a2enmod rewrite && systemctl reload apache2
Erreur de connexion à la base Vérifier les lignes DB_* du .env, puis php artisan config:clear
Upload d'images impossible Refaire l'étape 8 (droits)
Liens en http alors que le site est en HTTPS Corriger APP_URL dans le .env

Chemins importants

Élément Chemin
Application /var/www/bookstack
Configuration /var/www/bookstack/.env
Vhost Apache /etc/apache2/sites-available/bookstack.conf
Logs Apache /var/log/apache2/bookstack_*.log
Logs applicatifs /var/www/bookstack/storage/logs/laravel.log
Fichiers uploadés /var/www/bookstack/public/uploads et storage/uploads