Passer au contenu principal

Configuration Bookstak avec Caddy

Prérequis : 

  • Debian 10
  • Caddy 2
  • MariaDB
  • PHP 7.4

Installation PHP 7.4

apt install -y php7.4 php7.4-cli php7.4-fpm php7.4-tidy php7.4-curl php7.4-ldap php7.4-mcrypt php7.4-gd php7.4-xml php7.4-zip php7.4-mysql php7.4-mbstring php7.4-common

 

Création base de donnée pour bookstack

CREATE DATABASE bookstackDB;
GRANT ALL ON bookstackDB.* TO 'bookstack' IDENTIFIED BY 'TheBookStackADM';
FLUSH PRIVILEGES;

Création utilisateur caddy

groupadd --system caddy

useradd --system \
	--gid caddy \
	--create-home \
	--home-dir /var/lib/caddy \
	--shell /usr/sbin/nologin \
	--comment "Caddy web server" \
	caddy

Placer le fichier de démarrage sytemd

Emplacement: /etc/systemd/system
Nom du fichier: caddy.service

# caddy.service
#
# For using Caddy with a config file.
#
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
#
# WARNING: This service does not use the --resume flag, so if you
# use the API to make changes, they will be overwritten by the
# Caddyfile next time the service is restarted. If you intend to
# use Caddy's API to configure it, add the --resume flag to the
# `caddy run` command or use the caddy-api.service file instead.

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target

[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

Fichier Caddyfile

Emplacement: /etc/caddy/
Nom du fichier: Caddyfile

nomdedomaine.fr

root * /var/www/bookstack/public
encode zstd gzip
try_files {path} /index.php?{query}&p={path}
php_fastcgi unix//run/php/php7.4-fpm.sock
file_server


Droit fichier web pour caddy

chown -R www-data:www-data /var/www/bookstack