Configure bottle framework for Apache

Follow these steps to port over your local bottle framework onto an apache server that would run on http 80

1. Install the bottle framework on the server

2. Install mod_wsgi on the server

sudo apt-get install libapache2-mod-wsgi

This will install a .so module in Apache’s module directory:


It will also automatically configure Apache to load the mod_wsgi module upon restart. You can confirm the presence of the module in Apache’s available modules directory… as well as Apache’s enabled modules directory:



More details about installation and configuration on

3. Under the apache configuration – add a new file under sites-enabled and call this restapi. The contents of the restapi file would be like this:

<VirtualHost *:80>
        ServerAlias     www.your-alias.domain.pvt

    DocumentRoot    /var/www

        WSGIScriptAlias /               /var/www/restapi/restapi.wsgi
        WSGIDaemonProcess       restapi    threads=25
        WSGIScriptReloading     Off

    <Directory /var/www>
        Order allow,deny
        Allow from all

    <Directory /var/www/restapi>
        WSGIProcessGroup restapi
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all


4. Navigate to the restapi directory and create a file called restapi.wsgi. The contents of the restapi.wsgi should be something like this:

import sys, os, bottle

sys.path = ['/var/www/restapi/'] + sys.path

# Change working directory so relative paths (and template lookup) work again

import apiserver         # This loads the REST framework that you have implemented as (The file that handles get/post requests)

# ... build or import your bottle application here ...
# Do NOT use with mod_wsgi
application = bottle.default_app()

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s