Observations

situational inanity

Snapshots, Morocco 2012. In response to Imperfect Photography.

When fear of enslavement exceeds fear of an establishment.

When fear of enslavement exceeds fear of an establishment.

Let’s Play: Buzzword Bingo!

Brief install process for Pyramid and Couchdb on Cherokee with uWSGI.

Part 1 of 2 (part 2 here)

Today we’ll be using:

  • Ubuntu 11.10 (Oneiric Ocelot)
  • Python 2.7.2+
  • Cherokee 1.2.1
  • uWSGI 0.9.9.2
  • Pyramid 1.2
  • Couchdb 1.1

Note, you’ll need to install whatever dependencies you don’t alreay have. Check the individual (linked) project pages for full lists, pre apt-getting.

Cherokee

su@remote:~# add-apt-repository ppa:cherokee-webserver
su@remote:~# apt-get install cherokee
You want usage graphs?
su@remote:~# apt-get install libcherokee-mod-rrd
Access admin, get your password…
su@remote:~# cherokee-admin &
…and tunnel to get http://localhost:9090/ on local.
usr@local:~# ssh remote -L 9090:localhost:9090

If your server’s not running at the expected location, you need to go fix it.

uWSGI

su@remote:~# pip install uwsgi

Pyramid

su@remote:~# useradd -g 33 -m pyramid
su@remote:~# passwd pyramid
su@remote:~# mkdir -m 774 /var/www/app
su@remote:~# chown -R pyramid /var/www/app
su@remote:~# sudo -i -u pyramid
…unless you want a webapp under root?
pyramid@remote:~# virtualenv —no-site-packages /var/www/app
pyramid@remote:~# cd /var/www/app
pyramid@remote:/var/www/app# source bin/activate    # deactivate later, to exit
pyramid@remote:/var/www/app# easy_install pyramid

Wrapping it all up with a sample project…

pyramid@remote:/var/www/app# paster create -t pyramid_starter testapp
pyramid@remote:/var/www/app# cd testapp
pyramid@remote:/var/www/app/testapp# python setup.py install
Now add app entry and python home to the production.ini
[uwsgi]
wsgi-file = /var/www/app/testapp/pyramid.wsgi
home = /var/www/app
Create pyramid.wsgi…
from pyramid.paster import get_app
application = get_app(‘/var/www/app/testapp/production.ini’, ‘main’)
…setting as executable
pyramid@remote:var/www/app/testapp# chmod 775 pyramid.wsgi
Access Cherokee admin panel, add a new virtual server with the uWSGI wizard.
config path: /var/www/app/testapp/production.ini
doc root: /var/www/app/testapp
Save settings and check pyramid is now running at the expected location.
Then kill admin.
su@remote:~# killall cherokee-admin

Problems?

Try your error log…
su@remote:~# tail -f /var/log/cherokee/cherokee.error
…or run the Cherokee sources interpreter string from the command line.
pyramid@remote:~# /usr/local/bin/uwsgi -s 127.0.0.1:54265 —ini /var/www/app/testapp/production.ini
Else if the admin panel is acting strangely, disabling graphs/rrdtools can help - or perhaps brute-force a restart:
su@remote:~# /etc/init.d/cherokee stop
su@remote:~# pkill -9 -f cherokee
su@remote:~# /etc/init.d/cherokee start

Oh, You’re No Fun Anymore

Brief install process for Pyramid and Couchdb on Cherokee with uWSGI.

Part 2 of 2 (part 1 here)

Today we’ll be using:

  • Ubuntu 11.10 (Oneiric Ocelot)
  • Python 2.7.2+
  • Cherokee 1.2.1
  • uWSGI 0.9.9.2
  • Pyramid 1.2
  • Couchdb 1.1

Couchdb

su@remote:~# useradd -g 33 -m couchdb
su@remote:~# passwd couchdb
su@remote:~# sudo -i -u couchdb
…because databases are people too.
Use the build-couchdb script to bulid the latest version.
couchdb@remote:~# git clone git://github.com/iriscouch/build-couchdb
couchdb@remote:~# cd build-couchdb
couchdb@remote:~/build-couchdb# git submodule init
couchdb@remote:~/build-couchdb# git submodule update
You should screen this, it takes forever.
couchdb@remote:~/build-couchdb# rake
Edit /home/couchdb/build-couchdb/build/etc/couchdb/default.ini, modify…
bind_address = 0.0.0.0
Now will it blend (or run)?
couchdb@remote:~/build-couchdb# build/bin/couchdb &
All good? Then tunnel to get http://localhost:5984/_utils on local.
usr@local:~# ssh remote -L 5984:localhost:5984
And add an admin, for later.
couchdb@remote:~# curl -X PUT http://127.0.0.1:5984/_config/admins/username -d ‘“password”’

Couchdb & Pyramid

pyramid@remote:/var/www/app# source bin/activate
pyramid@remote:/var/www/app# pip install couchdb

…note that was all as the user pyramid in our virtualenv!

Now setup a project as in part 1 of this series. Add the Pyramid Quick Tutorial source as modified to fit couchdb. You can download my copy here. It contains most of the code files required, but note that you’ll need to add your own couchdb admin details to production.ini. Next:

pyramid@remote:/var/www/app/tasksapp# python setup.py install

…and restart Cherokee, depending on your settings.

Everything working? Great!

If not, see part 1 for troubleshooting tips. Or check out google. I hear it’s the next big thing.