diff --git a/README.md b/README.md index b596db8..d24f3d1 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,21 @@ -# Setup - -## Requirements +# Requirements - `Python >= 3.7` - `pip` - `Postgresql >= 11` - `OpenLDAP` +## Deployment +- `Apache2` +- `mod_wsgi` + +# Setup ## Set up Python environment `pip install -r requirements/production.txt` ## Set environmental variables -Alternatively, variables can be set in a `.env` file in `config/settings`. +**When deploying with Apache, environmental variables do not work!** +Variables can be set in a `.env` file in `config/settings`. + For Django related variables see [Django's documentation](https://docs.djangoproject.com/en/dev/ref/settings/). - `DJANGO_SECRET_KEY` - `DATABASE_URL` @@ -32,4 +37,37 @@ See [django-auth-ldap docs](https://django-auth-ldap.readthedocs.io/en/latest/au - `python manage.py update_index`. See [Wagtail docs](https://docs.wagtail.io/en/latest/reference/management_commands.html#update-index) ## Compile translation -- `python manage.py compilemessages`. \ No newline at end of file +- `python manage.py compilemessages`. See [Django docs](https://docs.djangoproject.com/en/2.2/ref/django-admin/#django-admin-compilemessages) + +## Collect static files +- `python manage.py collectstatic`. See [Django docs](https://docs.djangoproject.com/en/2.2/ref/contrib/staticfiles/#collectstatic) + +# Deployment with Apache and mod_wsgi +For details see [Django docs](https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/). + +## Example configuration +``` +# Load wsgi module +LoadModule wsgi_module modules/mod_wsgi.so + +Alias /media/ /path/to/mpicms/mpicms/media/ +Alias /static/ /path/to/mpicms/staticfiles/ + +# Static files should be access seperately + + Require all granted + + + + Require all granted + + +WSGIPythonHome /path/to/venv +WSGIScriptAlias / /path/to/mpicms/config/wsgi.py + + + + Require all granted + + +``` diff --git a/config/wsgi.py b/config/wsgi.py index 56de1ac..73692de 100644 --- a/config/wsgi.py +++ b/config/wsgi.py @@ -14,7 +14,7 @@ app_path = os.path.abspath(os.path.join( os.path.dirname(os.path.abspath(__file__)), os.pardir)) -sys.path.append(os.path.join(app_path, 'mpicms')) +sys.path.append(app_path) os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.production')