Production Server
Note
This guide explains how to set up a production server on Ubuntu 20.04.3 LTS (Focal Fossa). Other linux distributions should work just fine, but we don’t provide detailed instructions for them.
System requirements
Upgrade all packages:
sudo apt update && sudo apt -y upgradeInstall system requirements:
sudo apt -y install python3-venv python3-pip libcairo2 libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b
Integreat CMS Package
Choose a location for your installation, e.g.
/opt/integreat-cms/:sudo mkdir /opt/integreat-cms sudo chown www-data:www-data /opt/integreat-cmsCreate config and log files and set more restrictive permissions:
sudo touch /var/log/integreat-cms.log /etc/integreat-cms.ini sudo chown www-data:www-data /var/log/integreat-cms.log /etc/integreat-cms.ini sudo chmod 660 /var/log/integreat-cms.log /etc/integreat-cms.iniChange to a shell with the permissions of the webserver’s user
www-data:sudo -u www-data bashCreate a virtual environment:
cd /opt/integreat-cms python3 -m venv .venv source .venv/bin/activateInstall the Integreat cms inside the virtual environment:
pip3 install integreat-cmsNote
The command above resolves all dependencies to their newest compatible versions. To install exactly the versions this release was tested with, install the package without its dependencies first and then the lock file it bundles (see Bundled lock files):
# Install the Integreat CMS itself without resolving its dependencies pip3 install --upgrade --no-deps integreat-cms # Install the locked dependencies from the file bundled into the package, verifying their hashes pip3 install --no-deps --require-hashes -r "$(python3 -c 'import integreat_cms, pathlib; print(pathlib.Path(integreat_cms.__file__).parent / "requirements.lock.txt")')"In both invocations, the
--no-depsflag is required: without them, pip resolves the dependencies on top of the lock file, which defeats the point of locking. Run both commands on every upgrade and only restart the application after the second one. With pip 26.1 or later,pylock.tomlcan be used instead ofrequirements.lock.txt. To check whether an installation is in sync with its lock file, run the second command with--dry-run, which lists the packages it would change.Create a symlink to the integreat_cms/core/wsgi.py file to facilitate the Apache configuration:
ln -s $(python -c "from integreat_cms.core import wsgi; print(wsgi.__file__)") .Set the initial configuration by adding the following to
/etc/integreat-cms.ini(for a full list of all possible configuration values, have a look at example-configs/integreat-cms.ini):[integreat-cms] SECRET_KEY = <your-secret-key> FCM_CREDENTIALS = <path-your-firebase-credentials-file> BASE_URL = https://cms.integreat-app.de LOGFILE = /var/integreat-cms.logLeave the www-data shell:
exit
Static Files
Create root directories for all static files. It’s usually good practise to separate code and data, so e.g. create the directory
/var/www/integreat-cms/with the sub-directoriesstatic,media,xliff/uploadandxliff/download:sudo mkdir -p /var/www/integreat-cms/{static,media,pdf,xliff/{upload,download}}Make the Apache user
www-dataowner of these directories:sudo chown -R www-data:www-data /var/www/integreat-cmsAdd the static directories to the config in
/etc/integreat-cms.ini:STATIC_ROOT = /var/www/integreat-cms/static MEDIA_ROOT = /var/www/integreat-cms/media PDF_ROOT = /var/www/integreat-cms/pdf XLIFF_ROOT = /var/www/integreat-cms/xliffCollect static files:
cd /opt/integreat-cms sudo -u www-data bash source .venv/bin/activate integreat-cms-cli collectstatic exitSet up cronjobs to regularly delete outdated PDF and XLIFF files:
crontab -e0 0 * * * /usr/bin/find /var/www/integreat-cms/{pdf/*,xliff/{download,upload}/*} -mtime +7 -delete
Webserver
Install an Apache2 server with mod_wsgi:
sudo apt -y install apache2 libapache2-mod-wsgi-py3Enable the
rewriteandwsgimodules:sudo a2enmod rewrite wsgiSetup a vhost for the integreat-cms by using our example config: example-configs/apache2-integreat-vhost.conf and edit the your domain and the paths for static files.
Make sure that clients cannot set the X-Forwarded-For header. This header is used to determine a client IP behind a proxy for IP rate limiting.
Database
Install a PostgreSQL database on your system:
sudo apt -y install postgresqlCreate a database user
integreatand set a password:sudo -u postgres createuser -P -d integreatCreate a database
integreat:sudo -u postgres createdb -O integreat integreatAdd the database credentials to the config in
/etc/integreat-cms.ini:DB_PASSWORD = <your-password>Execute initial migrations:
cd /opt/integreat-cms sudo -u www-data bash source .venv/bin/activate integreat-cms-cli migrate
Redis Cache
Install a Redis database on your system which can be used as cache:
sudo apt -y install redis-serverUncomment the following lines in the redis configuration
/etc/redis/redis.confto make use of unix sockets:unixsocket /var/run/redis/redis-server.sock unixsocketperm 770Add the
www-datauser to theredisgroup to give it access to the socket:usermod -aG redis www-dataConfigure the integreat-cms to use the redis cache by adding the following values to
/etc/integreat.ini:REDIS_CACHE = True REDIS_UNIX_SOCKET = /var/run/redis/redis-server.sock
Email configuration
Add your SMTP credentials to
/etc/integreat.ini(for the default values, see example-configs/integreat-cms.ini):EMAIL_HOST = <your-smtp-server> EMAIL_HOST_USER = <your-username> EMAIL_HOST_PASSWORD = <your-password>