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.

2014-04-01

Boar on Freenas


mount -uw /


cd /mnt/dataset

Method one (get valid token from 'Download')1:

wget "http://boar.googlecode.com/issues/attachment?aid=920000000&name=install_boar.sh&token=XXXXXXXX" -O install_boar.sh

Method two:

cat >> install_boar.sh
#!/usr/local/bin/bash
#
# Install boar on FreeBSD
# Writen by: Kellen Fox
#
if [ "$(whoami)" != "root" ]; then
echo "You need to be root for this."
exit 1
fi

### These variables can be changed for other systems ###
#Where to install the files. Since this is a python package site-packages works nicely
INSTALL_DIR=/usr/local/lib/python2.7/site-packages/
# Where to put the boar script
BIN_DIR=/usr/local/bin/
# Package url
BOAR_URL=http://boar.googlecode.com/files/boar.29-Jul-2012.tar.gz

cd $INSTALL_DIR
curl $BOAR_URL | gunzip | tar -xpf -
cd boar
echo "Editing setup.py"
# comment out the second line "import py2exe"
sed -i .tmp '2 s/[^ ]*/#&/' setup.py && rm setup.py.tmp
/usr/local/bin/python setup.py build
/usr/local/bin/python setup.py install

ln -s ${INSTALL_DIR}boar/boar ${BIN_DIR}boar

^D

vi install_boar.sh
  • Change BOAR_URL to current 2
chmod +x install_boar.sh
./install_boar.sh
mount -ur /


References:
1 - Issue 92: setup.py fails on FreeBSD
2 - Boar: Simple version control and backup for photos, videos and other binary files