Skip to content

Commit

Permalink
WSGI setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Merlin Buczek committed Jun 10, 2019
1 parent 222859d commit afc1440
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
48 changes: 43 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -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`.
- `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
<Directory /path/to/mpicms/staticfiles>
Require all granted
</Directory>
<Directory /path/to/mpicms/mpicms/media>
Require all granted
</Directory>
WSGIPythonHome /path/to/venv
WSGIScriptAlias / /path/to/mpicms/config/wsgi.py
<Directory /path/to/mpicms/config>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
```
2 changes: 1 addition & 1 deletion config/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down

0 comments on commit afc1440

Please sign in to comment.