Thu, 07 Dec 2006

Pre-requisites for installing PyBlosxom

You will need:

  • a web-server that runs CGI
  • Python version 2.2 or later
  • a text editor (notepad, vi, emacs, nano, ...)

[23:49] | [] | #-permalink-#

Installation

These were the steps to setup the blog for this presentation on my Mac OSX 10.4 Notebook.

1. install pyblosxom python package after extracting the archive

$ sudo /usr/local/bin/python2.4 setup.py install --prefix=/usr/local 

2. install pyblosxom contrib (contributed plugins) after 
   extracting the archive

$ sudo cp -R contrib.1.3.0 /usr/local/lib/python2.4/site-packages/

3. create the necessary directories for the web site 

$ cd /Library/WebServer/
$ sudo  mkdir michipug-pyblosxom-Dec-2006
$ chown xxx   michipug-pyblosxom-Dec-2006
$ mkdir cgi-bin
$ mkdir blog
$ mkdir blog/entries
$ mkdir blog/flavours
$ mkdir blog/flavours/html.flav
$ mkdir blog/logs
$ mkdir static
$ mkdir css
$ mkdir graphics

4. copy the cgi and config file

$ cd path/to/pyblosxom_build_dirs/web
$ cp pyblosxom.cgi /Library/WebServer/michipug-pyblosxom-Dec-2006/cgi-bin/
$ cp config.py     /Library/WebServer/michipug-pyblosxom-Dec-2006/cgi-bin/
$ vi pyblosxom.cgi to change to #!/usr/local/bin/python2.4 

[23:48] | [] | #-permalink-#

Configuration

Configure the following in your apache configuration file(s) or in a .htaccess file.

1. configured apache with Listen,VirtualHost,Directory,Files 
   directives

# *****************************************************************
# *****************************************************************
# * for MichiPUG pyblosxom presentation Dec 2006
# *****************************************************************

Listen 9000
    
<VirtualHost *:9000>
    ServerAdmin sample@example.invalid
    DocumentRoot /Library/WebServer/michipug-pyblosxom-Dec-2006/
    ServerName 127.0.0.1   
    ErrorLog "/private/var/log/httpd/port-9000-error_log"
    AddHandler cgi-script .cgi
    ScriptAlias /cgi-bin/ /Library/WebServer/michipug-pyblosxom-Dec-2006/cgi-bin/
    DirectoryIndex cgi-bin/pyblosxom.cgi
    RewriteEngine On
    RewriteRule blog$              /cgi-bin/pyblosxom.cgi/                [last]
    RewriteRule blog(/.*)?$        /cgi-bin/pyblosxom.cgi$1               [last]
</VirtualHost>
    
<Directory "/Library/WebServer/michipug-pyblosxom-Dec-2006/">
    Options Indexes
    AllowOverride None
    Order allow,deny
    Allow from all 
</Directory>

<Directory "/Library/WebServer/michipug-pyblosxom-Dec-2006/cgi-bin/">
    Options ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<Files config.py> 
deny from all 
</Files>

# *****************************************************************
# * for MichiPUG pyblosxom presentation Dec 2006
# *****************************************************************
# *****************************************************************

3. configured pyblosxom by modifying the config.py file

$ diff config.py.orig config.py
12c12
< py['blog_title'] = "Another pyblosxom blog"
---
> py['blog_title'] = "MichiPUG PyBlosxom Presentation blog"
18c18
< py['blog_author'] = "name"
---
> py['blog_author'] = "Jim McDonald"
21c21
< py["blog_email"] = "email@blah.com"
---
> py["blog_email"] = "jimc_mcdonald@pobox.com"
33c33
< py["blog_rights"] = "Copyright 2005 Joe Bobb"
---
> py["blog_rights"] = "Copyright 2006 Jim McDonald"
36c36
< py['datadir'] = "/path/to/blog"
---
> py['datadir'] = "/Library/WebServer/michipug-pyblosxom-Dec-2006/blog/entries"
71a72
> py['flavourdir'] = "/Library/WebServer/michipug-pyblosxom-Dec-2006/blog/flavours"
79c80
< # py['base_url'] = "http://www.some.host/weblog"
---
> py['base_url'] = "http://127.0.0.1:9000/blog"
99a101
> py['plugin_dirs'] = ['/usr/local/lib/python2.4/site-packages/contrib.1.3.0/plugins/']
110a113
> py['load_plugins'] = ["pyfilenamemtime","pycalendar", "pycategories", "pyarchives"]
118a122
> py["static_dir"] = "/Library/WebServer/michipug-pyblosxom-Dec-2006/static"

3. copied the custom html flavour to ./blog/ and modified it to include the correct
   setting for the stylesheet 

4. copied the CSS stylesheet to ./css/ 

 

The PyBlosxom Configuration File: config.py

PyBlosxom's configuration file is called config.py, and basically contains a dict named py, whose entries are the configuration variables for PyBlosxom. This dict ends up getting passed all the way through the core processing engine. Some of the important values that you need to set are

py['datadir'] the directory of the root of the PyBlosxom data, which will contain all the blog entries.

py['plugin_dirs'] a list of directories containing the plugins that you wish to use.

py['load_plugins'] a list containing the names of the plugins that you wish to use.

In order to use plugins you need to correctly set py['plugin_dirs'] and place the corresponding entry in py['load_plugins']

You will need to be careful about operating system permissions between the web server user and the user PyBlosxom is running as. This will affect comment files and logs especially.

After these steps are complete the blog is functional.

Note: Normally you'd place your datadir blog entries outside of the root document directory of your web site!

[23:47] | [] | #-permalink-#

Test the cgi script

Run the pyblosxom.cgi cgi script from the commandline to verify the configuration.

$ ./pyblosxom.cgi 
Welcome to PyBlosxom's installation verification system.
------
]] printing diagnostics [[
pyblosxom:   1.3.2 2/13/2006
sys.version: 2.4.4 (#1, Oct 20 2006, 14:37:05)  
             [GCC 4.0.1 (Apple Computer, Inc. build 5363)]
os.name:     posix
codebase:    --default--
------
]] checking config file [[
config has 19 properties set.

   missing optional property: 'renderer'
   missing optional property: 'cacheDriver'
   missing optional property: 'cacheConfig'

Refer to the documentation for what properties are available
and what they do.
PASS: config file is fine.
------
]] checking datadir [[
PASS: datadir is there.  Note: this does not check whether
      your webserver has permissions to view files therein!
------
Now we're going to verify your plugin configuration.
=== plugin: 'pycalendar'
    file: /usr/local/lib/python2.4/site-packages/contrib.1.3.0/plugins/pycalendar.py
    version: $Id: pycalendar.py 883 2006-03-24 03:43:42Z willhelm $
    PASS
=== plugin: 'pycategories'
    file: /usr/local/lib/python2.4/site-packages/contrib.1.3.0/plugins/pycategories.py
    version: $Id: pycategories.py 883 2006-03-24 03:43:42Z willhelm $
missing optional config property 'category_template' which allows 
you to specify how the category hierarchy is rendered.  see
the documentation at the top of the pycategories plugin code 
file for more details.
    PASS
=== plugin: 'pyarchives'
    file: /usr/local/lib/python2.4/site-packages/contrib.1.3.0/plugins/pyarchives.py
    version: $Id: pyarchives.py 883 2006-03-24 03:43:42Z willhelm $
missing optional config property 'archive_template' which 
allows you to specify how the archive links are created.  
refer to pyarchive plugin documentation for more details.
    PASS

The following plugins do not support installation verification:
   'pyfilenamemtime' 
(/usr/local/lib/python2.4/site-packages/contrib.1.3.0/plugins/pyfilenamemtime.py)

[23:46] | [] | #-permalink-#