3. Deploying to a Web Server

3.1. General Information

3.1.1. Web Application Environment Variables

DJANGO_SETTINGS_MODULE
Set to SeismoWebPortal.site.settings. See the Django documentation for detailed information.
WEBPORTAL_MEDIA_ROOT
Full pathname of the directory where the portal will store all those images generated with GMT. Specfem 3D models are also stored under this directory.
WEBPORTAL_DATABASE_NAME
Full pathname of the SQLite database file.
WEBPORTAL_SECRET_KEY
Arbitrary string used to encrypt cookies. Keep this string a secret! XXX describe how to create one
WEBPORTAL_GMT_ROOT
Full pathname where GMT is installed. The portal appends bin to this pathname in order to run various GMT commands such as psmeca and psbasemap; e.g., $WEBPORTAL_GMT_ROOT/bin/psmeca.
WEBPORTAL_NETCDF_ROOT
Full pathname where netCDF is installed. Before running a GMT command, the portal sets the environment variable LD_LIBRARY_PATH to $WEBPORTAL_NETCDF_ROOT/lib. It does this simply so that GMT commands can execute; the portal does not interact with netCDF directly. XXX footnote

3.2. Apache

Set up SSL.

Beyond the scope of this document, but might be easy:

cd /etc/apache2/mods-enabled
ln -s ../mods-available/ssl.conf .
ln -s ../mods-available/ssl.load .

cd /etc/apache2/sites-enabled
ln -s ../sites-available/default-ssl 000-default-ssl


SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

Need mod-python:

cd /etc/apache2/mods-enabled
ln -s ../mods-available/python.load .

(Ubuntu creates symlink for you.)

3.2.1. Configure

See http://www.djangoproject.com/documentation/0.96/modpython/. Here is the virtual host config:

<Location "/portals/seismo/">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE SeismoWebPortal.site.settings
        #PythonDebug On

        SetEnv WEBPORTAL_MEDIA_ROOT /home/portal/www-data/media
        SetEnv WEBPORTAL_DATABASE_NAME /home/portal/www-data/database
        SetEnv WEBPORTAL_SECRET_KEY "$2k0qi00^76%1i9r5z@i#l@l($2&-r3&!37z00-vll&9#&(skg"
        SetEnv WEBPORTAL_GMT_ROOT /home/portal/opt/gmt
        SetEnv WEBPORTAL_NETCDF_ROOT /home/portal/opt/netCDF

        PythonPath "['/home/portal/lib/python2.4/site-packages'] + sys.path"

</Location>

Restart Apache.

But actually:

<Location "/portals/seismo/">
        PythonInterpreter seismo

        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE SeismoWebPortal.site.settings
        #PythonDebug On

        SetEnv WEBPORTAL_MEDIA_ROOT /home/portal/www-data/media
        SetEnv WEBPORTAL_DATABASE_NAME /home/portal/www-data/database
        SetEnv WEBPORTAL_SECRET_KEY "$2k0qi00^76%1i9r5z@i#l@l($2&-r3&!37z00-vll&9#&(skg"
        SetEnv WEBPORTAL_GMT_ROOT /home/portal/opt/gmt
        SetEnv WEBPORTAL_NETCDF_ROOT /home/portal/opt/netCDF

        PythonPath "['/home/portal/lib/python2.4/site-packages'] + sys.path"

</Location>

<Location "/magwebportal/">
        PythonInterpreter mag

        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE MagWebPortal.site.settings
        #PythonDebug On

        SetEnv WEBPORTAL_MEDIA_ROOT /home/portal/lib/python2.4/site-packages/MagWebPortal
        SetEnv WEBPORTAL_DATABASE_NAME /home/portal/www-data/mag-database
        SetEnv WEBPORTAL_SECRET_KEY "$2k0qi00^76%1i9r5z@i#l@l($2&-r3&!37z00-vll&9#&(skg"

        PythonPath "['/home/portal/lib/python2.4/site-packages'] + sys.path"

</Location>

Table Of Contents

Previous topic

2. Dependencies

This Page