<table class="provenance-header" style="border: 0; border-collapse: collapse; margin: 0 0 16px 0; width: 100%;">
<tr style="border: 0;">
<td style="border: 0; vertical-align: top; padding: 0 24px 0 0;">

> **Source:** [https://foxhop.net/f2924939-2f95-11f1-8a03-e86a64d24d78/setting-up-a-pylowiki-site](https://foxhop.net/f2924939-2f95-11f1-8a03-e86a64d24d78/setting-up-a-pylowiki-site)  
> **Snapshot:** 2026-09-14T11:21:36Z  
> **Generator:** Remarkbox `695de26`  
>
> *This is a thread snapshot. The living document lives at the source URI above — it may have been edited, extended, or replied-to since.*

</td>
<td style="border: 0; vertical-align: top; width: 200px; text-align: right;">

![Scan for living source](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKQAAACkAQAAAAAxzrjsAAABZ0lEQVR42tWXuXEEQQwDWUqA+WeJDCg2OIaMc1QFQ5p7Zw0sD9N8rubDUv3hq1XV2m+zH+r29qs+rd9crenZJ3ft2o9mm9FdrdPWvpptTrdK/H7dNqiL8rowwXjt7CDOl5i/APBjxXhgtWpRKx8f9GX83QD7AF/l3WV0HSK/fk+uzXBG14CNUXDsqx7SJRtQlRNEsXy77OXkZCtC8bIQW+QImkcm3nHGQQOxVyoviHEole8AU+eGFC47PQAilG+2dqXVB3PIX4e4IGzcWEFtD/GAx77Boy1Vd8xvHWTYG6oPGhd0QN6ggSPkLwSgzT2qUvXhIrw3d6QUv+0Yi2SWG1wojylmDwphcqxf6EC42rOqsTqpuaxb2q5chnxwHZPnMzfnWD/2oYGcCDlXHyS3n3mTRGzeoRe7ge6uYv3C/rq4V+X8bRPm9ilP1grqvnEe1JSc1w9ez2iVnCcZfhEUnS7H7//5n/UNh1PJfTwJdGUAAAAASUVORK5CYII=)

</td>
</tr>
</table>

# 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](https://foxhop.net/pylowiki#installation-and-setup){target="_blank"}.

In this tutorial we will be configuring pylowiki to run:

-   on ubuntu linux
-   as a wsgi application
-   with an apache2 webserver
-   in a python virtualenv
-   with a mysql database backend

<div>

</div>

## Get the Pylowiki sourcecode

The pylowiki sourcecode is hosted at
[bitbucket.org](http://bitbucket.org){rel="nofollow" target="_blank"}.
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.

::: {#cb3}
    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/](http://pylonshq.com/docs/en/1.0/gettingstarted/){rel="nofollow"
target="_blank"}

::: {#cb4}
    wget http://www.pylonshq.com/download/1.0/go-pylons.py

    python go-pylons.py virtpy
:::

To enable the virtual environment run:

::: {#cb5}
    source virtpy/bin/activate
:::

## Install your Pylowiki application

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

::: {#cb6}
    (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:

::: {#cb7}
    (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

    mysql>

    CREATE DATABASE mysite

    GRANT ALL PRIVILEGES ON mysite.* TO username@localhost IDENTIFIED BY 'passw0rd' WITH GRANT OPTION

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

::: {#cb9}
    sqlalchemy.url = mysql://username:password@127.0.0.1/mysite?charset=utf8
    sqlalchemy.pool_recycle = 3600
:::

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

::: {#cb10}
    (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:

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

    import site
    site.addsitedir('/absolute/path/to/virtpy/lib/python2.6/site-packages')

    # 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.

::: {#cb12}
    sudo vi 002-mysite

    #mysite.net

    #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
    </VirtualHost>
:::

Restart the apache2 service:

::: {#cb13}
    sudo service apache2 restart
:::

## foxhop — [Oct 08, 2010 03:23 pm](https://foxhop.net/f2924939-2f95-11f1-8a03-e86a64d24d78/setting-up-a-pylowiki-site#f3f502fc-2f95-11f1-83ad-e86a64d24d78)

Please contribute to this installation documentation.


---

**Source:** [https://foxhop.net/f2924939-2f95-11f1-8a03-e86a64d24d78/setting-up-a-pylowiki-site](https://foxhop.net/f2924939-2f95-11f1-8a03-e86a64d24d78/setting-up-a-pylowiki-site)  
**Snapshot:** 2026-09-14T11:21:36Z  
**Generator:** Remarkbox `695de26`
