2014-04-20

Uniform Server Zero + mod_wsgi + Falcon Framework on Windows 7

Setting up a local test environment before deployment on shared hosting (Dreamhost / Phusion Passenger) (assumes python already properly installed):
  • Install UniServerZ: Uniform Server - A lightweight mobile WAMP Server Solution.
  • Download1mod_wsgi library, extract,  and copy .so to UniserverZ\core\apache2\modules
  • Install Falcon: python -m pip install falcon
  • Edit httpd.conf:
  • add:
       LoadModule wsgi_module modules/mod_wsgi.so
       WSGIScriptAlias /app "${US_ROOTF_WWW}/passenger_wsgi.py"
  • Edit passenger_wsgi.py:
  • import falcon
    class Test:
       def on_get(self, req, resp):
          resp.status = falcon.HTTP_200
          resp.body = ('<h1>Test.</h1>')
    app = application = falcon.API('text/html')
    app.add_route('/', Test())
    
  • Hit local server(assumes default port): http://127.0.0.1/app/
1 Choosing the right library: match the version of python installed with downloads. Failure to do so results in the following errors:
\UniServerZ>httpd_z -t
httpd_z: Syntax error on line 187 of x:/xxx/UniServerZ/core/apache2/conf/httpd.conf: Cannot load modules/mod_wsgi.so into server: The specified module could not be found.
Occurs if the mod_wsgi.so version is different from python version installed. (What, the error should actually help you know that? ...)

\UniServerZ>httpd_z -t
httpd_z: Syntax error on line 187 of x:/xxx/UniServerZ/core/apache2/conf/httpd.conf: Cannot load modules/mod_wsgi.so into server: %1 is not a valid Win32 application.
Occurs if the .so is 64bit and installed UniServer is 32bit.

No comments: