Skip to content

Janeway, Apache and WSGI

Andy Byers edited this page Sep 14, 2017 · 14 revisions

This guide is a brief look at setting up Janeway with Apache and mod_wsgi in the live environment:

Note: you should not run this installer as root and will have to give the apache www-data user access to your folders inc .virtualenvs

sudo chown -R youruser:www-data /path/to/janeway/
&&
sudo adduser www-data youruser

Install apache and mod_wsgi:

sudo apt-get install apache2 libapache2-mod-wsgi-py3

Go the to sites-avaialble directory:

cd /etc/apache2/sites-available/

Add a new config file, you can call it whatever you want:

nano 000-janeway.conf

add the following:

<VirtualHost *:80>
        RewriteEngine on
        RewriteOptions Inherit

        Alias /media/ /path/to/janeway/src/media/
        <Directory /path/to/janeway/src/media>
                Require all granted
        </Directory>

        Alias /static/ /path/to/janeway/src/collected-static/
        <Directory /path/to/janeway/src/collected-static>
                Require all granted
        </Directory>

        WSGIApplicationGroup %{GLOBAL}
        WSGIScriptAlias / /path/to/janeway/src/wsgi.py
        WSGIDaemonProcess janeway python-path=/path/to/.virtualenvs/janeway/lib/python3.5/site-packages
        <Location />
        WSGIProcessGroup janeway
        </Location>
        <Directory /path/to/janeway/src//src>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        # http://wiki.apache.org/httpd/InternalDummyConnection
        # disable logging of the "(internal dummy connection)" requests.
        # may be skewing traffic reported by logwatch.
        SetEnvIf Remote_Addr "127\.0\.0\.1" loopback
        ErrorLog ${APACHE_LOG_DIR}/janeway_error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/janeway.log vhost_combined env=!loopback
</VirtualHost>

You may have to disable 000-default.conf as we want janeway.conf to be the default and pick up domains.

Then we need to edit the wsgi.py:

__copyright__ = "Copyright 2017 Birkbeck, University of London"
__author__ = "Martin Paul Eve & Andy Byers"
__license__ = "AGPL v3"
__maintainer__ = "Birkbeck Centre for Technology and Publishing"
"""
WSGI config for core project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os
import sys

from django.core.wsgi import get_wsgi_application
sys.path.append('/path/to/janeway/src')
sys.path.append('/path/to/.virtualenvs/janeway/lib/python3.5/site-packages')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")

application = get_wsgi_application()

Restart apache with:

service apache2 restart

Wiki has moved to read the docs.

Clone this wiki locally