Ceci est la documentation pour le code de développement actuel. Choisissez une version dans le menu pour voir la documentation des versions publiées depuis v0.7.5.

Installation sans Docker

This project is still young and isn't, at the moment, very stable, so please proceed with caution when running in production.

This method of installation is more involved, and therefore is for more experienced admins. Docker install is the recommended method as there may not be much support available for Dockerless installation. If you have expertise in this area, we would love your help to improve this documentation!

This install method assumes you already have ssl configured with certificates available.

Configuration du serveur

  • Obtenez un nom de domaine et configurez le DNS pour votre serveur. Vous devez faire pointer les serveurs de noms de domaine de votre fournisseur DNS vers le serveur où vous allez héberger BookWyrm. Voici les instructions pour DigitalOcean
  • Configurez votre serveur avec des pare-feu appropriés pour l'exécution d'une application web (ces instructions ont été testées avec Ubuntu 20.04). Voici les instructions pour DigitalOcean
  • Configurez un service de messagerie (tel que Mailgun) et les paramètres SMTP/DNS appropriés. Utilisez la documentation du service pour la configuration de votre DNS
  • Installez les dépendances. On debian this could look like apt install postgresql redis nginx python3-venv python3-pip python3-dev libpq-dev gunicorn gettext-base

Installez et configurez BookWyrm

La branche production de BookWyrm contient un certain nombre d'outils qui ne sont pas sur la branche main, prévus pour fonctionner en production, tels que des modifications de docker-compose pour mettre à jour les commandes par défaut ou la configuration des conteneurs, ou des modifications spécifiques à des containers pour activer des fonctionnalités telles que SSL ou des sauvegardes régulières. Tous ces changements n'ont pas nécessairement un impact sur l'installation sans docker, mais la branche production est néanmoins recommandée

Instructions pour l'exécution de BookWyrm en production sans Docker :

  • Créez et déplacez vous dans le répertoire où vous voulez installer BookWyrm. Par exemple /opt/bookwyrm : mkdir /opt/bookwyrm && cd /opt/bookwyrm
  • Get the application code, note that this only clones the production branch: git clone https://github.com/bookwyrm-social/bookwyrm.git --branch production --single-branch ./
  • Create your environment variables file, cp .env.example .env, and update the following. Passwords should generally be enclosed in "quotation marks". You can use bw-dev create_secrets to generate passwords in .env-file:
    • SECRET_KEY | A difficult to guess, secret string of characters.
    • DOMAIN | Votre domaine web
    • POSTGRES_PASSWORD | Utilisez un mot de passe sécurisé pour la base de données
    • POSTGRES_HOST | Mettez à localhost (la machine exécutant votre bdd)
    • POSTGRES_USER | Mettez à bookwyrm (recommendé) ou une valeur personnalisée (configurée plus tard)
    • POSTGRES_DB | Définir à bookwyrm
    • REDIS_ACTIVITY_PASSWORD | Laissez à blanc (adapté pour une machine locale avec un pare-feu)
    • REDIS_ACTIVITY_HOST | Mettez à localhost (la machine exécutant redis)
    • REDIS_BROKER_PASSWORD | Laissez à blanc (adapté pour une machine locale avec un pare-feu)
    • REDIS_BROKER_HOST | Mettez à localhost (la machine exécutant redis)
    • EMAIL_HOST_USER | L'adresse d'expéditeur de laquelle votre application enverra des emails
    • EMAIL_HOST_PASSWORD | Le mot de passe fourni par votre service d'emailing
  • If you are on Debian and some other operating systems, you may need to create the /var/cache/nginx directory:
mkdir /var/cache/nginx
chown www-data:www-data /var/cache/nginx
  • Configurez nginx
    • Copy the server_config to nginx's conf.d: cp nginx/locations /etc/nginx/conf.d/locations
    • Update nginx /etc/nginx/conf.d/locations:
      • Replace /app with your install directory /opt/bookwyrm everywhere in the file (including commented out)
    • Make a copy of the production template config and set it for use in nginx:
      • Set env-variables for DOMAIN and MAX_UPLOAD_MiB so envsubst can populate nginx templates. For example export DOMAIN=your-web-domain MAX_UPLOAD_MiB=100
      • envsubst '$DOMAIN,$MAX_UPLOAD_MiB' < nginx/server_config > /etc/nginx/conf.d/server_config
      • envsubst '$DOMAIN,$MAX_UPLOAD_MiB' < nginx/server_name > /etc/nginx/conf.d/server_name
      • envsubst '$DOMAIN,$MAX_UPLOAD_MiB' < nginx/https.conf > /etc/nginx/sites-available/bookwyrm.conf
    • If you are running another web-server on your host machine, you should use following command to use nginx as reverse-proxy: envsubst '$DOMAIN,$MAX_UPLOAD_MiB' < nginx/reverse_proxy.conf > /etc/nginx/sites-available/bookwyrm.conf
    • Update nginx /etc/nginx/sites-available/bookwyrm.conf:
      • Change the ssl_certificate and ssl_certificate_key paths to your fullchain and privkey locations if you are not using nginx as reverse-proxy
      • Change upstream addresses in lines 4 and 7 to server localhost:8000 and server localhost:8888. Vous pouvez choisir un port différent si vous le souhaitez
    • Enable the nginx config: ln -s /etc/nginx/sites-available/bookwyrm.conf /etc/nginx/sites-enabled/bookwyrm.conf
    • Rechargez la configuration nginx : systemctl reload nginx
  • Configurez l'environnement virtuel python
    • Make the python venv directory in your install dir: python3 -m venv ./venv
    • Install bookwyrm python dependencies with pip: ./venv/bin/pip3 install --upgrade "pip>=25.1.0" ./venv/bin/pip3 install --group main
  • Créez la base de données postgresql de bookwyrm. Make sure to change the password to what you set in the .env config: sudo -i -u postgres psql
CREATE USER bookwyrm WITH PASSWORD 'securedbypassword123';

CREATE DATABASE bookwyrm TEMPLATE template0 ENCODING 'UNICODE';

ALTER DATABASE bookwyrm OWNER TO bookwyrm;

GRANT ALL PRIVILEGES ON DATABASE bookwyrm TO bookwyrm;

\q
  • Migrez le schéma de la base de données en exécutant venv/bin/python3 manage.py migrate
  • Initialisez la base de données en exécutant venv/bin/python3 manage.py initdb
  • Compile the themes by running venv/bin/python3 manage.py compile_themes
  • Create the static files by running venv/bin/python3 manage.py collectstatic --no-input
  • Si vous souhaitez utiliser un stockage externe pour les ressources statiques et les fichiers multimédias (comme un service compatible S3), suivez les instructions jusqu'à être redirigé ici
  • Créez et configurez votre utilisateur bookwyrm
    • Créez l'utilisateur système bookwyrm: useradd bookwyrm -r
    • Modifiez l’appartenance du répertoire d’installation de bookwyrm : chown -R bookwyrm:bookwyrm /opt/bookwyrm
    • Vous devriez maintenant exécuter les commandes liées à bookwyrm avec l'utilisateur de bookwyrm : sudo -u bookwyrm echo I am the $(whoami) user
  • Configure, enable, and start BookWyrm's systemd services:

    • Copy the service configurations by running cp contrib/systemd/*.service /etc/systemd/system/
    • Enable and start the services with systemctl enable bookwyrm bookwyrm-worker bookwyrm-scheduler
  • Générez le code administrateur avec sudo -u bookwyrm venv/bin/python3 manage.py admin_code, et copiez le pour l'utiliser lors de la création du compte administrateur.

  • Vous pouvez obtenir ce code à n'importe quel moment en ré-exécutant la commande. Voici un exemple de sortie :
*******************************************
Use this code to create your admin account:
c6c35779-af3a-4091-b330-c026610920d6
*******************************************
  • The application should now be running at your domain. When you load the domain, you should get a configuration page to confirm your instance settings, and a form to create an admin account. Utilisez votre code d'administration pour vous inscrire.

Congrats! You did it!! Configure your instance however you'd like.

Finding log files

Like all software, BookWyrm can contain bugs, and often these bugs are in the Python code and easiest to reproduce by getting more context from the logs.

If you use the provided systemd service configurations from contrib/systemd you will be able to read the logs with journalctl:

# viewing logs of the web process
journalctl -u bookwyrm

# viewing logs of the worker process
journalctl -u bookwyrm-worker

# viewing logs of the scheduler process
journalctl -u bookwyrm-scheduler

Feel free to explore additional ways of slicing and dicing logs with flags documented in journalctl --help.

While BookWyrm's application logs will most often be enough, you can find logs for other services like Nginx, PostgreSQL, or Redis are usually in .log files located somewhere in /var/logs.

Participer

Voir Participer pour plus de détails.