serveur_hebergement:i_hate_money

I hate money

I hate money est un logiciel permettant de gérer les budgets partagés, comme pour le jour de l'an par exemple. Chaque participant peut rentrer de nouvelles factures et le logiciel calcule automatiquement qui doit combien à qui. Ça fait comme tricount sauf que c'est libre et peut être auto-hébergé

L'accès au logiciel se fait via une interface web. Il vous faudra donc un serveur web, qui sera Apache dans mon cas, et un nom de domaine. Je vais installer I hate money sur mon Raspberry (Raspbian 11).

Commençons par installer les pré-requis

sudo aptitude install python3-dev libssl-dev libapache2-mod-wsgi-py3 python3-venv

Créez un environnement virtuel dans /var/www

sudo -u www-data python3 -m venv /var/www/ihatemoney

Changez le propriétaire par votre utilisateur :

sudo chown -R utilisateur:utilisateur /var/www/ihatemoney/

Puis accédez-y

cd /var/www/ihatemoney

Activez l'environnement virtuel

source bin/activate

Installez I hate money

pip install ihatemoney

Installez PyMySQL

pip install 'PyMySQL>=0.9,<1.1'

C'est terminé pour l'installation. Passons à la configuration

Créez les répertoires de I hate money

sudo mkdir /etc/ihatemoney /var/lib/ihatemoney

Générez le fichier de configuration

ihatemoney generate-config ihatemoney.cfg > ihatemoney.cfg

Copiez le fichier dans /etc/ihatemoney :

sudo cp ihatemoney.cfg /etc/ihatemoney/

Mettez les droits adéquats

sudo chmod 740 /etc/ihatemoney/ihatemoney.cfg
sudo chgrp www-data /etc/ihatemoney/ihatemoney.cfg
sudo chown www-data /var/lib/ihatemoney

Créez le mot de passe admin :

ihatemoney generate_password_hash

Ca va vous générer un hash qu'il faudra mettre dans le fichier de configuration.

Ouvrez le fichier de configuration

sudo nano /etc/ihatemoney/ihatemoney.cfg

Modifiez le fichier de configuration afin qu'il ressemble à ceci

# You can find more information about what these settings mean in the
# documentation, available online at
# http://ihatemoney.readthedocs.io/en/latest/installation.html#configuration

# Turn this on if you want to have more output on what's happening under the
# hood. DO NOT TURN IT ON IN PRODUCTION.
DEBUG = False

# The database URI, reprensenting the type of database and how to connect to it.
# Enter an absolute path here.
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://ihatemoney:motdepasse@localhost/ihatemoney' #à adapter
SQLACHEMY_ECHO = DEBUG

# Will likely become the default value in flask-sqlalchemy >=3 ; could be removed
# then:
SQLALCHEMY_TRACK_MODIFICATIONS = False

# This secret key is random and auto-generated, it protects cookies and user sessions
SECRET_KEY = "ipuw14#=*m5_%1f7mg-!z8-bunv@xod65_19*umx)4cy#4f-^0"

# A python tuple describing the name and email adress of the sender of the mails.
MAIL_DEFAULT_SENDER = ("Budget manager", "adresse mail") #à adapter

# If set to True, a demonstration project will be activated.
ACTIVATE_DEMO_PROJECT = False

# If not empty, the specified password must be entered to create new projects.
# DO NOT enter the password in cleartext. Generate a password hash with
# "ihatemoney generate_password_hash" instead.
ADMIN_PASSWORD = "hashmotdepasse" #Mettez ici le hash généré précédemment.

# If set to True (default value) anyone can create a new project.
ALLOW_PUBLIC_PROJECT_CREATION = True

# If set to True, an administration dashboard is available.
ACTIVATE_ADMIN_DASHBOARD = True

# You can change the timezone used to display time.  By default it will be
#derived from the server OS.
#BABEL_DEFAULT_TIMEZONE = "Europe/Paris"

# Enable secure cookies. Requires HTTPS. Disable if you run your ihatemoney
# service over plain HTTP.
SESSION_COOKIE_SECURE = True

# You can activate an optional CAPTCHA if you want to. It can be helpful
# to filter spammer bots.
# ENABLE_CAPTCHA = True

# You may want to point to a special legal page, for instance to give information
# about GDPR, or how you handle the data of your users.
# Set this variable to the URL you want.
# LEGAL_LINK = ""

MAIL_SERVER = "adresse serveur mail" #à adapter
MAIL_PORT = 587 #à adapter
MAIL_USE_TLS = True #à adapter
MAIL_USERNAME = "nom d'utilisateur" #à adapter
MAIL_PASSWORD = "mot de passe" #à adapter

Pensez à adapter les lignes où il est indiqué “#à adapter”.

Créez la base de donnée mysql ihatemoney ainsi que l'utilisateur ihatemoney ayant pour mot de passe celui que vous avez indiqué dans le fichier de configuration.

Il ne reste plus qu'à créer le vhost Apache

Créez un fichier de configuration Apache2 :

sudo nano /etc/apache2/sites-available/budget.nomdedomaine.conf

Collez-y le retour de la commande précédente et complétez pour qu'il ressemble à ceci :

<VirtualHost *:80>
 
        ServerName budget.nomdedomaine.fr
 
        Redirect / https://budget.nomdedomaine.fr/
 
</VirtualHost>
 
<VirtualHost *:443>
 
        ServerName budget.nomdedomaine.fr
 
        WSGIDaemonProcess ihatemoney user=www-data group=www-data threads=5 python-home=/var/www/ihatemoney
        WSGIScriptAlias / /var/www/ihatemoney/lib/python3.9/site-packages/ihatemoney/wsgi.py
        WSGIPassAuthorization On
 
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/budget.access.log combined
        ErrorLog ${APACHE_LOG_DIR}/budget.error.log
 
        SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/nomdedomaine.fr/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/nomdedomaine.fr/privkey.pem
 
        <Directory /var/www/ihatemoney/lib/python3.9/site-packages/ihatemoney>
                WSGIProcessGroup ihatemoney
                WSGIApplicationGroup %{GLOBAL}
                Require all granted
        </Directory>
 
        Alias /static/ /var/www/ihatemoney/lib/python3.9/site-packages/ihatemoney/static/       
 
</VirtualHost>

Activez le vhost

sudo a2ensite budget.nomdedomaine.conf

Redémarrez Apache

sudo systemctl restart apache2

I hate money est maintenant accessible depuis l'adresse configuré dans le vhost Apache. Si vous cliquez sur la roue crantée en bas à droite, après avoir rentré le mot de passe admin vous aurez accès à la zone d'administration.

Si vous voulez mettre à jour Ihatemoney dans le futur, il vous suffit de vous rendre dans le répertoire /var/www/ihatemoney puis d'activer l'environnement virtuel :

source bin/activate

puis de lancer :

pip install -U ihatemoney
Vous pourriez laisser un commentaire si vous étiez connecté.
  • serveur_hebergement/i_hate_money.txt
  • Dernière modification : 2023/08/15 20:42
  • de fate