[Home]PythonCommunityServerSetupHowto

CommunityServerWiki | RecentChanges | Preferences

Difference (from prior minor revision) (no other diffs)

Changed: 7c7,9
First, create the user that will run PyCS. Log in as this user. You will probably have to do something like this:
First, you need to have a PostgreSQL server ready. It can be on the local machine, or on another machine on the network.

Now, create the user that will run PyCS. Log in as this user. You will probably have to do something like this:

Added: 78a81,82

Now set up your PostgreSQL database. You need to create a database called 'pycs' and a user called 'pycs', then edit pg_hba.conf to allow TCP access to the database. Detailed instructions are in the README file that will be in ~/src/pycs/README.

Here is a fairly complete HOWTO for installing PythonCommunityServer. If you follow these instructions, please drop me a line to tell me how accurate / useful they were. Don't hesitate to mail me if you have any trouble; I'm happy to help you out.

-- PhillipPearson


First, you need to have a PostgreSQL server ready. It can be on the local machine, or on another machine on the network.

Now, create the user that will run PyCS. Log in as this user. You will probably have to do something like this:

adduser www-pycs
su - www-pycs

(Note: you want to do the rest of these instructions as the www-pycs user. If you do them as root, you will end up with a copy of PyCS that runs as root, and lives inside /root, which probably isn't what you want.)

Now, create a directory to hold all the code for things we are about to compile.

mkdir ~/src

Now, get Python (the latest version) from http://www.python.org/download/ ...

cd ~/src
wget http://www.python.org/ftp/python/2.2.3/Python-2.2.3.tgz
tar -vzxf Python-2.2.3.tgz

And compile it:

cd Python-2.2.3
./configure --prefix=$HOME/pycs && make && make install

(This makes a private copy of Python, just for your community server).

Now, get the PyXML source from http://pyxml.sourceforge.net/ - this isn't really needed if you only have small changes on your system, but improves performance drastically if you have larger upstreams, as the XML parser in Python is written in Python and this package contains a parser based on expat (a parser written in C).

cd ~/src
wget http://optusnet.dl.sourceforge.net/sourceforge/pyxml/PyXML-0.8.3.tar.gz
tar xvfz PyXML-0.8.3.tar.gz

And now compile and install it:

cd PyXML-0.8.3
$HOME/pycs/bin/python setup.py build
$HOME/pycs/bin/python setup.py install

Now, get MetaKit from http://www.equi4.com/pub/mk/ and compile it:

cd ~/src
wget http://www.equi4.com/pub/mk/older/metakit-2.4.9.2.tar.gz
tar -vzxf metakit-2.4.9.2.tar.gz
cd metakit-2.4.9.2
cd unix
./configure --prefix=$HOME/pycs --with-python=$HOME/pycs && make && make install && make install-python

(Now we have a copy of MetaKit installed, with the Python extension enabled).

Now, get the PyCS code:

cd ~/src
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/pycs login
(the password is blank - just hit enter)
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/pycs co pycs

Download Medusa:

cd ~/src
wget http://www.amk.ca/files/python/medusa-0.5.4.tar.gz
cd pycs
tar -vzxf ../medusa-0.5.4.tar.gz
mv medusa-0.5.4 medusa

Now install PyCS:

make install PREFIX=$HOME/pycs USER=$USER ROOT=$USER

NB: this is a GNU-style Makefile, so if you are on a platform that doesn't use GNU Make by default, e.g. FreeBSD?, you probably want to say gmake install ... instead of make install ....

Now set up your PostgreSQL database. You need to create a database called 'pycs' and a user called 'pycs', then edit pg_hba.conf to allow TCP access to the database. Detailed instructions are in the README file that will be in ~/src/pycs/README.

Now edit $HOME/pycs/etc/pycs/pycs.conf:

Change the serverurl variable to be the URL of your server. (This is important - if you don't, the style sheets won't show up on the rankings and updates pages! If you're installing on port 5445, put :5445 at the end of the URL.)

Change the servermailto variable to be an email address where bounces and status reports for feedback mails should go to.

Change maxusernum to a reasonable value. If you set it to 1, you will only be able to create one user on the server (do this if you have a private server like LouisGerbarg). Set it to 100 to allow 100 people to create blogs there.

Phew! I think that's it ;-)

Test it to make sure it goes:

$HOME/pycs/bin/python $HOME/pycs/usr/lib/pycs/bin/pycs.py
tail -f $HOME/pycs/var/log/pycs/etc.log

You should see some startup notes. If everything looks good, go to http://yourserver:5445/ and make sure the front page shows up.

Congratulations - you now have a working PythonCommunityServer!

Note that the server is running on port 5445, but the URLs it will pass out to users will be for port 80; PyCS assumes that it will be running on a machine which already has a web server (configured as a front-end proxy) on port 80. As such, you need to do one of the following:

RewriteEngine On
RewriteRule (.+) http://localhost:5445/~~vhost~~/%{HTTP_HOST}$1 [P,L]

If you use manila-style addresses, you should put in an equivalent ServerAlias directive, for example like:

ServerAlias *.pycs.net

And don't forget to set up an * A record in your domain to point to your webserver.

Now run apachectl restart to force Apache to understand the new rules.

More configuration

Front page

If you don't like the default login page (and you aren't expected to like it), copy $HOME/src/pycs/www/index.html to local_index.html, edit that, and run make install again (as above) to copy it into the right place.

Friendly URLs

To find out how to give people friendly URLs (like http://www.pycs.net/devlog/ rather than http://www.pycs.net/users/0105568/), look at the instructions in the file $HOME/pycs/etc/rewrite.conf.

Password authentication

If you want to password-protect some blogs or your whole server, create a file called $HOME/pycs/etc/pycs/users.conf and put in one line per user you want to create. Read authorizer.py for more information on the format. Basically it's:

username:md5 hash of password:comma separated list of things the user can get at

To make some of the server public, make a user with no name and password. To allow everyone to get at the front page and updates, for example, put in the following line:

::public

Getting it to run from init.d

cp ~/src/pycs/init_pycs /etc/init.d/pycs
chmod +x /etc/init.d/pycs

Edit /etc/init.d/pycs and change ROOTDIR to point to your root dir (/home/www-pycs/pycs if you followed the instructions above for installation).

Now you need to set up your rc*.d symlinks. On Debian, you can do it like this:

update-rc.d pycs defaults

Future stuff - running with PostgreSQL

This doesn't work yet, but when it does, you'll want to install pyPgSQL and mxDateTime like this:

1. install mxDateTime from http://starship.python.net/~lemburg/mxDateTime.html

cd $HOME/src
wget http://www.egenix.com/files/python/egenix-mx-base-2.0.5.tar.gz
tar -vzxf egenix-mx-base-2.0.5.tar.gz
cd egenix-mx-base-2.0.5
$HOME/pycs/bin/python setup.py install

2. install pyPgSQL from http://pypgsql.sourceforge.net/

cd $HOME/src
wget http://umn.dl.sourceforge.net/sourceforge/pypgsql/pyPgSQL-2.4.tar.gz
tar -vzxf pyPgSQL-2.4.tar.gz
cd pypgsql
$HOME/pycs/bin/python setup.py install

CommunityServerWiki | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited January 28, 2005 9:57 am by 203-79-71-98.adsl.paradise.net.nz (diff)
Search: