Login or register    

Setting up a pylowiki site

This page will outline the steps needed to setup a production pylowiki site.

If you are interested in running a demo or local version of pylowiki, check out the minimal pylowiki setup instructions.

In this tutorial we will be configuring pylowiki to run:

Get the Pylowiki sourcecode

The pylowiki sourcecode is hosted at bitbucket.org. You will need mecurial (hg) revision control to download the source.

For debian or ubuntu

sudo apt-get install mercurial

Once you have mercurial you need to clone the pylowiki sourcecode

hg clone http://bitbucket.org/russellballestrini/pylowiki

mv pylowiki mysite

Now you should have the sourcecode in local filesystem. You might want to come up with a workflow to maintain your changes and still accept revisions from the upstream pylowiki repository. I'll leave that up to you.

Fix file permissions

The web server account only needs access to a few directories. All the other files may be owned by your id.

Run the following commands from the root of your Pylowiki project directory to correct permissions.

mkdir egg-cache data

sudo chgrp -R www-data pylowiki/public/attachment
sudo chmod -R 774 pylowiki/public/attachment

sudo chgrp -R www-data egg-cache
sudo chmod -R 774 egg-cache

sudo chgrp -R www-data data
sudo chmod -R 774 data

Get a Pylons virtual environment

Official Pylons setup notes: http://pylonshq.com/docs/en/1.0/gettingstarted/

wget http://www.pylonshq.com/download/1.0/go-pylons.py

python go-pylons.py virtpy

To enable the virtual environment run:

source virtpy/bin/activate

Install your Pylowiki application

Make sure your currently inside your virtual python environment. Your shell should look like this:

(virtpy)user@host$ python setup.py develop

Notice the (virtpy)? The above command will install Pylowiki and all its dependencies into your virtual pythons site-lib.

Configure Pylowiki - prod.ini

The following command should be run in the root of your pylowiki project. This will create a configuration ini named prod.ini:

(virtpy)user@host$ paster make-config Pylowiki prod.ini

Open prod.ini for editing and make changes to reflect your environment. Database settings, public wiki registration, all the tweak-able settings are declared in the ini.

Prepare mySQL Database

Login to mySQL as root.

mysql -u root -p




Now make sure the prod.ini reflects these database settings:

sqlalchemy.url = mysql://username:password@
sqlalchemy.pool_recycle = 3600

Now we can let Pylowiki create all the database tables by issuing the following command:

(virtpy)user@host$ paster setup-app prod.ini

Configure mod_wsgi dispatch file

First step is to create the mod_wsgi dispatch file.

From the root directory of the Pylowiki project, create a dispatch.wsgi file with the following content:

# Add the virtual Python environment site-packages directory to the path
import sys
sys.stdout = sys.stderr

import site

# Avoid ``[Errno 13] Permission denied: '/var/www/.python-eggs'`` messages
import os
os.environ['PYTHON_EGG_CACHE'] = '/absolute/path/to/pylowiki/egg-cache'

# Load the Pylons application
from paste.deploy import loadapp
application = loadapp('config:/absolute/path/to/pylowiki/prod.ini')

Configure apache2 virtualhost

Create a domain file under /etc/apache2/sites-enabled.

 sudo vi 002-mysite


#pylons embeded mod_wsgi
<VirtualHost *:80>
       ServerName www.mysite.net
       ServerAlias mysite.net
       ServerAdmin admin@mysite.com

       # ReWrite URL to WWW
       RewriteEngine On
       RewriteCond %{HTTP_HOST} ^mysite.net
       RewriteRule (.*) http://www.mysite.net$1 [R=301,L]

       # Log Files
       ErrorLog /var/log/apache2/error-mysite.log
       CustomLog /var/log/apache2/access-mysite.log combined

       # Setup mod_wsgi
       WSGIScriptAlias / /absolute/path/to/pylowiki/dispatch.wsgi

Restart the apache2 service:

sudo service apache2 restart


foxhop 07:23 PM 10-08-2010

Please contribute to this installation documentation.

Leave a comment

Please login or register to leave a comment!