Installing Thiblo under Ubuntu Linux

In this manual, we focus on installing Thiblo on the latest Ubuntu Linux distribution, at the time of this writing, Hardy Heron (8.04).

Get the source

Download the sources under ~/thiblo/trunk/ and ~/thiblo/services/:

mkdir ~/thiblo
cd ~/thiblo
svn co trunk
svn co services

Note, that Django web framework will be checked out automatically as an svn external into ~/thiblo/django directory.

Install required packages

sudo apt-get install apache2-mpm-prefork python-yaml libapache2-mod-python \
                     python-json python-urljr python-imaging memcached \
                     python-openid python-setuptools

Install Python memcached client library

tar xzf python-memcached-latest.tar.gz
cd python-memcached-x.yy
sudo python install

Install GWT and addons

  1. Install the Java Runtime Environment.
sudo apt-get install sun-java6-jre
  1. Download latest Google Web Toolkit for your OS from and unpack it to any place. You need only gwt-user.jar and gwt-dev-***.jar files from the distribution, which you need to copy to thiblo/trunk/lib/gwt. (In case you would like to use the so called 'hosted mode' of gwt, you need the whole distribution there, not just the two jars. Most probably you won't.)
cd ~
tar xjf gwt-linux-${VERSION}.tar.bz2
cp gwt-linux-${VERSION}/{gwt-user.jar,gwt-dev-linux.jar} ~/thiblo/trunk/lib/gwt/
  1. Download GWT-Ext library and put gwtext.jar into lib/gwt/addons. Currently tested with version 2.0.2.
cd ~
unzip -j gwtext-${VERSION}.zip gwtext-${VERSION}/gwtext.jar
mkdir ~/thiblo/trunk/lib/gwt/addons
cp gwtext.jar ~/thiblo/trunk/lib/gwt/addons/

Create a DB


sudo apt-get install mysql-server python-mysqldb

While installing mysql-server you'll be asked to give a password for the root MySQL user. Do it. After install edit the /root/.my.cnf file like this:

sudo su -
cat > ~/.my.cnf <<'EOF'
user            = root
password        = myrootpw

user            = root
password        = myrootpw
chmod 600 ~/.my.cnf

This is needed (the [mysqladmin] part) for the MySQL's system cron jobs. And this way you won't forget the password. :)

Check your MySQL installation:

sudo -H mysqlshow
# +--------------------+
# |     Databases      |
# +--------------------+
# | information_schema |
# | mysql              |
# +--------------------+

Global configuration

We need to do the following changes in the global MySQL config file, /etc/mysql/my.cnf. (Put the definitions anywhere in the appropriate sections.)

character-set-server = utf8

default-character-set = utf8

Restart mysqld with sudo /etc/init.d/mysql restart

Create user and database

sudo -H mysql <<EOF
GRANT ALL ON thiblo.* TO 'thiblo'@'localhost' IDENTIFIED BY 'thiblopw';

Change thiblopw to a secret password of your choice. But beware, that it'll be saved in the mysql history file (.mysql_history). If you did not saved the root password in .my.cnf change the command to mysql -u root -p mysql.

Create local domains

Add a virtual host to your /etc/hosts file:

sudo su -
cat >> /etc/hosts <<EOF

Configure Thiblo.Py

You can see all default settings in ~/thiblo/trunk/, however, you should not put developer-specific values there.

Instead, create a file in the same directory and put your configuration into that.



DATABASE_OPTIONS = {"init_command": "SET storage_engine=InnoDB"}

DATABASE_NAME = 'thiblo'
DATABASE_USER = 'thiblo'
DATABASE_HOST = 'localhost'

SECRET_KEY = 'someuniquestring'

CACHE_BACKEND = 'memcached://'


Configure Apache

Create a virtual host by copying the Apache settings below to a file named /etc/apache2/sites-available/thiblo:

<VirtualHost *>
  DocumentRoot /home/$USER/thiblo/trunk/

  ErrorLog /var/log/apache2/error.log
  LogLevel warn
  CustomLog /var/log/apache2/access.log combined

  Header Set Cache-Control "max-age=0, no-store"

  SetHandler python-program
  PythonHandler django.core.handlers.modpython
  PythonDebug On

  # NOTE: we use installation directory here and not its parent.
  PythonPath "['/home/$USER/thiblo/trunk/'] + sys.path"

  <Location "/apps/account/gwt-ext">
    SetHandler None

  <Location "/static">
    SetHandler None

  <Location "/var/files">
    SetHandler None

  <Directory />
    Order Allow,Deny
    Allow from all

And for cross-domain authentication services (/etc/apache2/sites-available/thiblo-services):

<VirtualHost *>
  DocumentRoot /home/$USER/thiblo/services/master_domain/
  ServerAlias *

  <Directory />
    Order Allow,Deny
    Allow from all

Enable this server, and also the headers module:

sudo a2ensite thiblo
sudo a2ensite thiblo-services
sudo a2enmod headers

Restart your Apache:

sudo /etc/init.d/apache2 restart

Create database structure and import initial data

To do this move to your installation directory and run:

cd ~/thiblo/trunk
python syncdb
python import initial-data --path initial-data
python compile

That's all (almost)

Open your favorite browser (right now, it needs to be firefox or internet explorer) and go look at!

Note: any time you change any python code, you need to restart the apache server. (It is quite common to be amused by the miracle of restart not always being necessary. The explanation is that separate apache copies have separate compiled copies of the codebase. If you have, say, 20 apache backends running, then they are going to get the requests round-robin, so, for some time, you are going to get newly compiled server side copies handling your request. This miracle though doesn't even last for 3 days...)