setting-up-a-pylowiki-site

setting-up-a-pylowiki-site

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 </pylowiki#installation-and-setup>_.

In this tutorial we will be configuring pylowiki to run:

.. contents::

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

.. code-block:: shell

sudo apt-get install mercurial

Once you have mercurial you need to clone the pylowiki sourcecode

.. code-block:: shell

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.

.. code-block:: apache

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/

.. code-block:: apache

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

python go-pylons.py virtpy

To enable the virtual environment run:

.. code-block:: apache

source virtpy/bin/activate

Install your Pylowiki application

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

.. code-block:: php

(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:

.. code-block:: php

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

.. code-block:: mysql

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:

.. code-block:: ini

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:

.. code-block:: php

(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:

.. code-block:: python

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

.. code-block:: apache

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

Restart the apache2 service:

.. code-block:: apache

sudo service apache2 restart

foxhop — Oct 08, 2010 03:23 pm

Please contribute to this installation documentation.