i.e. Jonathan Abbett — web crafter, healthcare designer, amateur kosher cheesemaker.

Setting up mod_wsgi on WampServer

12 March 2013
How to deploy a Python app when you're the lone Windows user in a team of MacHeads

I'm using Windows 7 and Python 2.7. I'm running a Flask app as alias /api/

General Resources

Installing mod_wsgi

  1. Install Python
  2. Install a 32-bit version of WampServer
  3. Download mod_wsgi Windows binary and copy into WampServer's /bin/apache/apacheX.X.X/modules directory
  4. Edit WampServer's httpd.conf file to load the new module, around line 128, e.g.

    LoadModule wsgi_module modules/

Configuring a WSGIScriptAlias

  1. Create a WSGI file. Here's mine, stored with our application code, referencing our package

    import sys
    sys.path.insert(0, 'c:/path/to/python/application/code')
    from import app as application
  2. Use the WampServer system tray interface to create a basic Apache alias Creating an alias in WampServer

  3. Use same interface to "Edit the alias" (opens Notepad)
  4. Change Alias to WSGIScriptAlias, remove the trailing slash after the relative URL, and change the directory location to point directly to your WSGI file. Simplify the Directory directives. Here's my alias file, api.conf:

    WSGIScriptReloading On
    WSGIScriptAlias /api "c:/path/to/python/application/code/app.wsgi" 
    <Directory "c:/path/to/python/application/code">
        Order deny,allow
        Allow from all
  5. Start/restart your Apache service. Python app is now accessible through http://localhost/api/

comments powered by Disqus
Uncaught Exception

Uncaught Exception

Array and string offset access syntax with curly braces is deprecated


anchor/libraries/markdown.php on line 1396


#0 [internal function]: System\Error::shutdown()
#1 {main}