apache2 wsgi #6

Description

Install apache2 with mod_wsgi
Install python dependencies, from requirements.txt or from directory
Install ruby dependencies, from Gemfile or from directory
Extract app files
Serve the app on ports 80 and 443


Apache WSGI charm

This is a Juju charm for setting up an Apache mod_wsgi server for a basic Python WSGI app.

Usage

Deploy the charm

juju deploy ~nottrobin/trusty/apache2-wsgi

Add a project

The charm will just show a basic Apache2 welcome page, until you give it a URL from which to download a correctly configured WSGI app:

juju set app_tgz_url=http://example.com/my-project.tgz

It will then download the project, extract it, and restart Apache, attempting to run it.

Mongodb

If your app wants to make use of a MongoDB server, you can do that by adding a relation:

juju deploy mongodb
juju add-relation apache-wsgi mongodb

Now the MongoDB URI for your application to use will be available in the environment variable MONGODB_URI.

Configuring

By default, the WSGI file (wsgi_file_path) is expected to be at [project]/app.py, and the application name (wsgi_app_name) is expected to be app. This is in line with Flask defaults.

Any required python modules should be listed in [project]/requirements.txt (pip_requirements_path) and if you want pip to install them from local files instead of from PyPi, include the local packages in [project]/pip-cache (pip_cache_path).

For a full list of configuration options, see config.yaml.

Configuration

ssl_certificate
(string) Base64 encoded certificate file for SSL
apache_conf_path
(string) Path within the project to a custom apache configuration template Defaults to using the charm's template at [charm]/templates/wsgi-app.conf
wsgi_file_path
(string) The location (within the project) of the WSGI script
application.py
server_name
(string) The servername for inclusion in the Apache configuration
*
nagios_check_string
(string) The string for nagios to check is in the `nagios_check_uri` page
static_url_path
(string) The URL path to access static files
static
ssl_keyfile
(string) Base64 encoded keyfile for SSL
app_tgz_url
(string) A url where a gzipped tarball of the application files can be downloaded
pip_requirements_path
(string) A path (within the project) to pip requirements file - set this to blank to prevent installing from PyPi
requirements.txt
wsgi_app_name
(string) The name of the application inside the WSGI file
application
nagios_check_uri
(string) Relative URI for nagios to check against Nagios will expect a 200 status and a string, set in `nagios_check_string`
/
pip_no_index
(boolean) Prevent pip connecting to Python Package Index to download packages
apt_dependencies
(string) Space separated list of extra apt packages to be installed.
environment_variables
(string) A dictionary of environment variables to be set in the instance
pip_cache_path
(string) A path (within the project) to python dependencies
pip-cache
nagios_environment
(string) Name of the environment for use in nagios
wsgi-apps
static_path
(string) The path to the static folder within the application
static