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.
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
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 dataGet a Pylons virtual environment
Official Pylons setup notes: http://pylonshq.com/docs/en/1.0/gettingstarted/
To enable the virtual environment run:
Install your Pylowiki application
Make sure your currently inside your virtual python environment. Your shell should look like this:
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:
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:
sqlalchemy.url = mysql://username:password@127.0.0.1/mysite?charset=utf8
sqlalchemy.pool_recycle = 3600Now we can let Pylowiki create all the database tables by issuing the following command:
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
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.
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:
Remarkbox
Comments
Please contribute to this installation documentation.
export