Install Trac on Debian Squeeze
This post aims to provide a step-by-step on how to install Trac in Debian and get it working. These “instructions” were created exactly the way I setup my server. So paths and setup information can be modified for your project. The idea was this: there are many guides out there which provide the same information but in a more generic way; this post provides exact path information and such so that there is concrete, real world example of what needs to be done.
CAUTION: This post is a work in progress so there are many things which might not be properly documented and could have adverse effect.
Install Necessary Applications
sudo aptitude install trac bzr trac-bzr trac-spamfilter postgresql python-psycopg2 apache2 libapache2-mod-wsgi
Prepare Database
sudo vim /etc/postgresql/8.4/main/pg_hba.conf
Add following lines:
local tracdb tracuser password
host tracdb tracuser 127.0.0.1/32 md5
host tracdb tracuser 192.168.1.0/24 md5
psql template1 -W postgres
create database tracdb with encoding = 'utf8';
create user tracuser password 'password';
grant all on database tracdb to tracuser;
sudo /etc/init.d/postgresql-8.4 reload
Prepare Directories
cd /media/shared/Admin/
cd /home/codeghar/
mkdir /home/codeghar/trac
cd trac
cd /home/codeghar/trac/
mkdir repo env
cd /home/codeghar/trac/repo/
bzr init
Create Trac Project
cd /media/shared/Admin/env/
cd /home/codeghar/trac/env/
trac-admin $(pwd) initenv
trac-admin /home/codeghar/trac/env/ initenv
Project Name [My Project]> codeghartrac
Database connection string [sqlite:db/trac.db]> postgres://tracuser:password@localhost/tracdb
Repository type [svn]> bzr
Path to repository [/path/to/repos]> /media/shared/Admin/trac/repo
Enable Bazaar with Trac
To get Trac working with bzr, edit the trac.ini file (Hat tip: bzr – trac integration)
vim /media/shared/Admin/trac/env/conf/trac.ini
And add the following two lines, if they don’t already exist
[components]
tracbzr.* = enabled
First Test
Check if everything is working as it should be
tracd --port 8000 /media/shared/Admin/trac/repo/
Trac with WSGI and Apache
cd /media/shared/Admin/trac/www/
trac-admin /media/shared/Admin/trac/env/ deploy /media/shared/Admin/trac/www/
trac-admin /home/codeghar/trac/env/ deploy /home/codeghar/trac/www/
Put the following in your Virtual Host:
WSGIScriptAlias / /home/codeghar/trac/www/cgi-bin/trac.wsgi
<Directory /home/codeghar/trac/www/cgi-bin/trac.wsgi>
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
And then reload Apache. Your site is now available at http://yourip/
Hat tip: View of /packages/trac/trunk/debian/README.Debian; bazaar & trac-bzr; Recipe Installing Trac with PostgreSQL on CentOS4.2; Trac and mod_wsgi;
Debian Boot Messages
Want to see the messages flying on the screen when your computer boots after it has completed started? There are two things which will help you: dmesg and bootlogd. dmesg prints out the bootup messages. As far as I understand, it stores messages for the last boot only. Once you reboot, the last messages are replaced by messages of the new boot. But dmesg doesn’t show all messages. So you have to look at bootlogd, which does record all boot messages. To enable it in Debian Squeeze, edit the /etc/default/bootlogd file
sudo vim /etc/default/bootlogd
and change
BOOTLOGD_ENABLE=No
to
BOOTLOGD_ENABLE=yes
On your next boot (or reboot), boot messages should be available at /var/log/boot.
Hat tip to Where is the boot log in debian sarge ??
Debian aptitude History
How can we get a history of aptitude activity in Debian Squeeze? It’s simple: check out the /var/log/dpkg.log file. According to How to show apt log history, there existed a tool called apt-history, but it doesn’t any more. It further recommends a bash function called apt-history, which can be installed on your machine. Since I love to chain commands together, and haven’t wrote a single bash file ever, I thought what would be interesting to write myself? Below are the results (all commands are on one line even though blog formatting may indicate otherwise):
Get a list of installed and upgraded packages, with the activity date:
grep -i -w '\(install\|upgrade\)' /var/log/dpkg.log | cut -d' ' -f1,3,4 | uniq | less
Get a list of unique activities performed by aptitude:
cut -d' ' -f3 /var/log/dpkg.log | sort | uniq | less
Get a list of packages handled by aptitude, and the number of times they were handled:
cut -d' ' -f4 /var/log/dpkg.log | sort | uniq -c | less
Above commands and “scripts” were just some ways to analyze the log file. I am sure you can find some other, more interesting things to do with the file. Please share them with us.
Django in Debian Lenny
Installing Django in Debian is very similar to in Ubuntu. Here we will use Postgresql so there will be a slight difference from when using MySQL.
sudo aptitude install postgresql python-psycopg2 python-django
Debian Lenny Minimal Desktop
After you have read my post on minimal install of Debian, you may want something more than the command line, i.e. a minimal desktop. Although there are many, many minimal desktop environments (or simply window managers, etc.), I chose to go with Xfce. It is a good compromise between a desktop environment (DE) and minimal desktop. It is faster than Gnome or KDE and is still a DE. But what do you need to have it installed?
First off, you need an X server, and X.org is a very good (maybe only?) option. You also need a display manager. XDM, GDM, and KDM are three commonly used display managers. I chose XDM but it wasn’t very pretty to look at. Then I chose GDM over KDM because it required less packages, and it was pretty. Finally, I needed to install Xfce 4. All of this was installed with just one command:
sudo aptitude install xorg gdm xfce4
If you want to use minimal Gnome or KDE desktops, you can replace xfce4 with gnome-core and kde-core, like so:
sudo aptitude install xorg gdm gnome-core
If using KDE, you might want to try KDM instead of GDM.
sudo aptitude install xorg kdm kde-core
Hat tip: HOWTO: Minimal Debian Install (GNOME/KDE); Where do you set the default display manager to be xdm?
Debian Minimal Install
I like to do a minimal install of Debian and then only add the packages I need. I took the Lenny RC1 net install CD and installed from it. When the installer prompts to install software, I uncheck Desktop Envrionment and also the Standard System. This way only the very base system is installed. After installation, I usually run the following commands as root user:
aptitude install sudo vim
update-alternatives --config editor [I choose vim.basic as my editor of choice]
visudo [add my first user -- other than root -- to the sudoers file]
After this I am ready to use my regular user, using sudo if required. Now I install packages as and when required.