Mammoth
  • |
  • Contact
  • |
CMD | Command Prompt, Inc. - PostgreSQL Solutions, Support & Hosting
  • |
  • |
  • |
  • |
  • |
Configuring Pylons on Ubuntu Hardy
Posted Friday Feb 6th, 2009 03:36pm
by Joshua Drake
| Permalink

Follow cmdpromptinc on Twitter


I recently configured a complete Pylons + PostgreSQL environment for a customer. The operating system was (of course) Ubuntu Hardy. The system included the use of Simpycity and WSGI. Although I could never done it without the Pylons documentation, I found that it was unnecessary complicated for those who just want to get it done. These are the steps I took:

Install some dependencies: The use of apt-get here is wonderful because I didn't even have apache2 installed yet.

jd@hardy:~$ sudo apt-get install python-dev python-setuptools \
python-psycopg2 libapache2-mod-wsgi
jd@hardy:~$ sudo easy_install pylons 
jd@hardy:~$ sudo easy_install genshi
Set up a generic location for python egg cache:
jd@hardy:~$ sudo mkdir /home/pylons
jd@hardy:~$ sudo chgrp www-data /home/pylons
jd@hardy:~$ sudo chmod 770 /home/pylons
Enable mod-wsgi
jd@hardy:~$ cd /etc/apache2/mods-enabled
jd@hardy:/etc/apache2/mods-enabled$ sudo ln -sf ../mods-available/mod-wsgi.* .
Initialize your HelloWorld app
jd@hardy:~$ mkdir www
jd@hardy:~$ cd /var/www; ln -sf /home/jd/www jd
jd@hardy:~$ cd jd
jd@hardy:~$ paster create -t pylons helloworld
Selected and implied templates:
  Pylons#pylons  Pylons application template

Variables:
  egg:      helloworld
  package:  helloworld
  project:  helloworld
Enter template_engine (mako/genshi/jinja/etc: Template language) ['mako']: genshi
Enter sqlalchemy (True/False: Include SQLAlchemy 0.4 configuration) [False]: 
Enter google_app_engine (True/False: Setup default appropriate for Google App Engine) [False]: 
Creating template pylons
Creating directory ./helloworld
  Recursing into +package+
[...]
Notice the choice of genshi as the template language.

Configure your wsgi handler

jd@hardy:~$ mkdir ~/etc
jd@hardy:~$ cd etc; joe helloworld.wsgi
The helloworld.wsgi looks like this
import os, sys
sys.path.append('/home/jd/www/helloworld')
os.environ['PYTHON_EGG_CACHE'] = '/home/pylons'

from paste.deploy import loadapp

application = loadapp('config:/home/jd/www/helloworld/development.ini')
Edit your 000-default file
jd@hardy:~$ sudo joe /etc/apache2/sites-enabled/000-default
Add your WSGIScriptAlias
WSGIScriptAlias /jd/helloworld /home/jd/etc/helloworld.wsgi
Restart Apache
jd@hardy:~$ sudo /etc/init.d/apache2 restart
You should be good to go!

Categories: PostgreSQL, OpenSource

blog comments powered by Disqus

Copyright © 2000-2012 Command Prompt, Inc. All Rights Reserved. All trademarks property of their respective owners.