Turbogears 2.1 on Fedora

This post shows how to install Turbogears2 (TG2) in a Python virtual environment. (Update: Using Fedora 14)

Install required software:

yum install python-setuptools python-virtualenv

PostgreSQL dependencies (needed by PyGreSQL)

yum install gcc postgresql-devel

For MySQL backend, dependencies:

yum install gcc mysql-devel

Install TG2 in virtual env: (as root)

mkdir -p /usr/local/pythonenv
virtualenv --no-site-packages /usr/local/pythonenv/HelloWorld

Activate virtual env:

source /usr/local/pythonenv/HelloWorld/bin/activate

Install PostgreSQL database components: (in virtualenv, as root)

easy_install PyGreSQL
easy_install psycopg2

Install TG2.1: (in virtualenv, as root)

easy_install -i http://www.turbogears.org/2.1/downloads/current/index tg.devtools
easy_install -i http://www.turbogears.org/2.1/downloads/current/index Genshi
easy_install tw.jquery

Start developing TG2 app:

Note: Another way to add dependencies – edit setup.py, add package name to ‘install_requires’ variable. For MySQL, add ‘MySQL-python’

Activate virtualenv first (as regular user – ‘webmaster’)

source /usr/local/pythonenv/HelloWorld/bin/activate

Create TG2 app:

paster quickstart HelloWorld

Install required packages for this new app: (in virtual env, as root)

cd HelloWorld/
python setup.py develop

Make sure to use new PostgreSQL DSN format: (development.ini)

postgresql://username:[email protected]:port/databasename

Populate database (as regular user, refer HelloWorld/helloworld/websetup.py)

paster setup-app development.ini

Launch TG standalone server

paster serve --reload development.ini

… and start coding / debugging at http://localhost:8080

To change default URL address: (development.ini)

host =
port = 5000
Turbo + Gear

PostgreSQL on Fedora

PostgreSQL (Update: Using Fedora 14)

Install PostgreSQL & phpPgAdmin (web-based Postgres administration)

yum install postgresql postgresql-server phpPgAdmin

Initialize database

service postgresql initdb

Start PostgreSQL service

service postgresql start

Create password for user ‘postgres’ (in the system)

passwd postgres

Login as user ‘postgres’

su - postgres

Create password for user ‘postgres’ (in the database)

psql -d template1
alter user postgres with password 'password';

Exit psql shell:


Let Postgres allow authentication using password: (/var/lib/pgsql/data/pg_hba.conf)

# "local" is for Unix domain socket connections only
local   all         all                               md5
local   all         all                               ident
# IPv4 local connections:
host    all         all          md5
host    all         all          ident
# IPv6 local connections:
host    all         all         ::1/128               md5
host    all         all         ::1/128               ident

md5 – allow authentication using password
ident – authentication as system user

Restart PostgreSQL

service postgresql restart

Enable service:

chkconfig postgresql on


Create phpPgAdmin by copying from original config file: (/usr/share/phpPgAdmin/conf)

cp config.inc.php-dist config.inc.php

Allow login from phpPgAdmin: (/usr/share/phpPgAdmin/conf/config.inc.php)

$conf['extra_login_security'] = false;

Apache setting, add your IP address to allow access to the application (/etc/httpd/conf.d/phpPgAdmin.conf)

Allow from

Reload httpd. Open phpPgAdmin (http://localhost/phpPgAdmin). Login as ‘postgres’

Add new user: (PostgreSQL > Roles > Create role)

Create role (user) ‘webmaster’, inherits privileges from user ‘postgres’ & allow login

Create database: (PostgreSQL > Database > Create database)

Create database ‘helloworld’ using Unicode encoding

Grant permission on database: (PostgreSQL > helloworld > Privileges > Grant)

User ‘webmaster’ is granted ‘All privileges’

Check connection & configuration

psql -h localhost helloworld webmaster

Install Fedora as server

This installation exclude desktop environment, therefore it uses only command line interface. (Update: Based on Fedora 14)

During installation of Fedora, for software set, select ‘Minimal’, then choose to ‘Customize Now’. In customization section, for ‘Servers’ category, select only servers that you need: Web Server, PostgreSQL; then for ‘Base System’ category, select ‘Administration Tools’

Post installation configuration:

Set SELinux to ‘permissive’ (/etc/sysconfig/selinux)


Enable / disable certain services:

chkconfig [servicename] on|off

Disable: NetworkManager, firstboot, pcscd, cups (unless you connect this server with a printer), sendmail (unless you want to send e-mail using it)

Enable: httpd, mysqld, network

Note: We use ‘network’ instead of ‘NetworkManager’ to manage internet connection

Edit network interface: (/etc/sysconfig/network-scripts/ifcfg-eth0)


Restart the server

init 6

After restart, update the system:

yum install yum-fastestmirror yum-presto -y
yum update -y
X-less Fedora server on VBox


Add new user (‘webmaster’):

adduser webmaster
passwd webmaster

Install vim (CLI text editor):

yum install vim-enhanced


Better reference: http://www.thegeekstuff.com/2014/12/patch-command-examples/

yum install patch

To create patch:

diff -crB OriginalFolder ModifiedFolder > folder.patch

-c: context
-r: recursive (multiple level dir)
-B: ignore blank lines

To apply patch:

(dry run first, at target folder – to check for any error)

patch --dry-run -p1 -i folder.patch

If dry run success, do real patching:

patch -p1 -i folder.patch
Monkey patch

Compass & rubygem

Compass is a stylesheet authoring framework that makes your stylesheets and markup easier to build and maintain. – http://compass-style.org/

To install in Fedora:

yum install rubygems
gem install compass

By default, Compass is using Blueprint CSS framework – http://www.blueprintcss.org/

To kickstart a project:

compass -f blueprint project-name

To start designing website using Compass:

cd project-name
compass -w

It will watch for file changes and recompile *.sass source file into *.css

Reference on how to use Compass – http://wiki.github.com/chriseppstein/compass/
Sass reference – http://sass-lang.com/

Some of design using Compass + Blueprint CSS framework:

Web design #1
Web design #2
Web design #3