-
Notifications
You must be signed in to change notification settings - Fork 0
Server configuration
- Apache2
- python3-pip
- virtualenv
- libapache2-mod-wsgi-py3
- PostgreSQL
We use Django on the server side, which is a web framework written in Python. Deploying Django with Apache and mod_wsgi
is a tried and tested way to get Django into production. mod_wsgi
is an Apache module which can host any Python WSGI application.
The required python packages are collected in the file requirements/local.txt
. The idea behind having a separate base
, local
, and production
requirement file is to distinguish between development and production environment. base
lists packages required for all environments, whereas local
is meant for development and production
is meant for production.
At the moment, production
is the same as base
.
To allow for multiple Python projects to be set up on the same server, we use virtualenv
to separate the Python packages required for Civic Data from the Python packages directly installed on the server. The root folder of the virtualenv
is ./venv
. To activate the virtual environment, run source venv/bin/activate
from the root folder.
To set up the virtual environment from the beginning, run the following commands from the root folder:
virtualenv venv
source venv/bin/activate
pip3 install -r requirements/local.txt
The settings for the site can be found in /etc/apache2/sites-available/civicdata.conf
.
PostgreSQL is serving the database for the website. The database name, user, and password can be found in ./.env
file.
For a new installation of Postgres, password-based authentication must be enabled in the /etc/postgresql/9.5/main/pg_hba.conf
file. Search for and edit the line
# "local" is for Unix domain socket connections only
local all all md5
After editing the configuration file, restart the Postgres service: sudo service postgresql restart
.
How to serve Django applications with Apache and mod_wsgi
Django deployment with mod_wsgi