Serving Arches with Apache

When you are putting your Arches project in production, you’ll need to serve it with a webserver. The following is a guide using Apache as an example, split into two sections:

Setup Apache

During development, it’s easiest to use the Django webserver to view your Arches installation. However, once you are ready to put the project into production, you’ll have to use a more efficient webserver like Apache or nginx.

We have the most experience using Apache, which is very easy to install and configure. The following instructions work for Ubuntu 14.04, minor changes may be necessary for a different OS.

  1. Get apache2 and mod_wsgi

    $ sudo apt-get install apache2
    $ sudo apt-get install libapache2-mod-wsgi
  2. Create the Python process

    In order to properly configure Apache, we must:

    • Create a python daemon process
    • Set the path to your project’s file and reference to the python daemon process created above
    • Give Apache access to the main project directory

    All of these tasks are handled by adding a block of code to Apache’s ../sites-enabled/000-default.conf file. Use this command to open the file

    $ sudo nano /etc/apache2/sites-enabled/000-default.conf

    and paste the following code into the <VirtualHost *:80> stanza, changing directory and file paths where necessary:

    WSGIDaemonProcess arches python-path=/home/ubuntu/Projects/my_project:/home/ubuntu/Projects/ENV/lib/python2.7/site-packages
    WSGIScriptAlias / /home/ubuntu/Projects/my_project/my_project/ process-group=arches
    <Directory /home/ubuntu/Projects/my_project>
       Options Indexes FollowSymLinks
       AllowOverride None
       Require all granted

    If you intend to allow users to sync data from Arches Collector you will also need to include the following directive:

    WSGIPassAuthorization on

    Use ctrl+x to save the file.

    You may find it helpful to read the Official Django Documentation on serving Django apps with Apache and mod_wsgi.

  3. Set file system permissions for Apache

    Now we must give Apache write-permission in a few locations. We’ll do that by first changing the permissions of the necessary files and directories, and second by setting the Apache user as the group.

    $ sudo chmod 775 /home/ubuntu/Projects/my_project/my_project
    $ sudo chgrp www-data /home/ubuntu/Projects/my_project/my_project
    $ sudo chmod 664 /home/ubuntu/Projects/my_project/my_project/arches.log
    $ sudo chgrp www-data /home/ubuntu/Projects/my_project/my_project/arches.log


    On Ubuntu the Apache user is www-data (used in the example below), but on CentOS it is httpd.

    These commands should give Apache sufficient permissions to create and modify the arches/uploadedfiles directory (where user uploads are stored by default) and the arches/tileserver directory where Tilestache caches tiles that it renders.


    Please post to the Arches forum if you find that more permissions need to be modified, or that these directions can be simplified further.

  4. Restart Apache.


    $ sudo service apache2 restart


    $ sudo /sbin/service httpd restart

    You should now be able to view your app from any web browser by navigating directly to your IP address (you don’t need to run the Django dev server now).


    With Apache serving Arches, any changes to a .py file will not be reflected until you restart Apache:

If you are still in development and just want to use Apache instead of the Django server (and keep getting the lengthy Django error messages instead of a 500 page), you can stop here. Otherwise, you’ll need to continue on to handle your app’s static files.

Handling Static Files

There are two cases in which you need to follow these directions to handle static files (js, css, and images):

  • You are going to set DEBUG = False, at which point Django will no longer serve them, or
  • You are leaving DEBUG = True but are developing and serving your project from a non-root location, say instead of
  1. Create static files directory

    This directory can be placed anywhere. In the example below we are putting it inside of your project.

    $ mkdir /home/ubuntu/Projects/my_project/my_project/static
  2. Configure your Arches project settings

    Now open your (or file, and add these lines to it.

    STATIC_ROOT = os.path.join(PACKAGE_ROOT, 'static')
    STATIC_URL = "/static/"

    This will point Django to your new static directory, and also tell it how to create a URL that points to that directory.

  3. Collect the static files

    With your virtual environment activated, enter your project’s top directory and run this command:

    $ python collectstatic

    Watch as all of your static files (including those that come standard with Django) are copied to the new directory. Now we are ready to tell Apache where to find them.


    With Apache serving your app you must run python collectstatic any time you make any changes to static files.

  4. Configure Apache settings


    $ sudo nano /etc/apache2/sites-enabled/000-default.conf

    to edit the default Apache configuration file. Find your <VirtualHost *:80> stanza with some familiar code in it. Below the original code you added, paste this block, changing paths as necessary.

    Alias /static/ /home/ubuntu/Projects/my_project/my_project/static/
    <Directory /home/ubuntu/Projects/my_project/my_project/static>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted

    The Alias line tells Apache where to look when Django sends it the /static/ URL, and the subsequent block allows Apache access to your newly created static directory.

  1. Restart Apache.

    $ sudo service apache2 restart