I have recently read Getting Things Done (GTD) by David Allen. My geek life is the usual “too much to do in so little time” and I keep forgetting all kinds of important stuff. I saw a lot of FOSS sites covering GTD in the past few months so I decided to give it a go, read the book and play with all kinds of software. I quickly came across Tracks, a nice looking GTD application to manage your actions.
Unfortnately it's written in Ruby on Rails which can be a bit of a pain to set up under Linux, especially if you want to use Apache as the webserver instead of the built-in WEBrick server. I’m already running Apache on my server and I didn’t feel like running a second webserver on a different, non-standard port just for this one app. It took me quite a bit of time to piece it all together, but here’s how I set up Tracks in Debian Lenny.
Installing Ruby on Rails and mod_fcgid
Installing Ruby on Rails is the easy part. Starting with Debian Lenny it all comes prepackaged, so all we need to do is install a couple of packages from the repository.
- aptitude install rails rake ruby rdoc irb libapache-mod-fcgid libfcgi-ruby1.8 rubygems1.8 libmysql-ruby
The last two packages aren’t strictly necessary for Ruby on Rails, but they are dependencies for Tracks. If you are going to use sqlite as the database backend for Tracks, you can skip libmysql-ruby.
Installing and configuring Tracks
Now it gets a bit hairier. First off, none of the currently released versions of Tracks will work on Debian Lenny. There appears to be some conflict between Ruby 1.8.7 and both Tracks 1.5 and tracks 1.6. I have no idea if the problem is caused by Tracks, Ruby or the Debian packagers but it simply won’t work. You will get strange NoMethodError errors or simply a HTTP 500 server error. So, we will need to install the current development branch of Tracks instead.
You can download Tracks 1.7-devel from GitHub. Unpack it somewhere conveniently. In my example I will be installing Tracks to /var/www/tracks-devel. Installation is pretty much as described in the Tracks manual.
First copy log.tmpl, config/database.yml.tmpl and config/environment.rb.tmpl to the variants without the .tmpl extension. Then you can edit database.yml and environment.rb to suit your needs. If you are using a MySQL database then you will need to populate the new database with tables.
- rake db:migrate RAILS_ENV=production
Now it’s time to configure Apache and tell it to run Tracks using mod_fcgid. In the example below I will be running tracks in it's own virtual host on http://tracks.example.org, so change that to whatever meets your need. Start off with a basic virtual host configuration.
- <VirtualHost *:80>
- DocumentRoot /var/www/tracks-devel/public
- ServerName tracks.example.org
- ServerSignature On
- LogLevel warn
- ErrorLog /var/log/apache2/error.log
- CustomLog /var/log/apache2/access.log combined
- </VirtualHost>
Now we add a handler for fcgi files and tell Apache to execute these with fcgid. We also add a RAILS_ENV environment variable to tell Tracks to execute in production mode instead of in development or test mode.
- AddHandler fcgid-script .fcgi
- DefaultInitEnv RAILS_ENV production
- <Files *.fcgi>
- SetHandler fcgid-script
- Options ExecCGI +FollowSymLinks
- </Files>
Now we need a bit of mod_rewrite magic. In the current setup, not all the requests end up properly at the dispatch.fcgi script. We use a rewrite rule to rewrite all requests to dispatch.fcgi with the exception of requests for actually existing files. If we don’t add that exception then CSS sylesheets and javascript files cannot be loaded.
- <Directory /var/www/tracks-devel/public>
- RewriteEngine on
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule ^/(.*) dispatch.fcgi [QSA,L]
- </Directory>
Now you can restart Apache and visit http://tracks.example.org/signup in order to create your Tracks admin account and start using it. Below is the full Apache configuration file. I hope this will help you to get things done!
- <VirtualHost *:80>
- DocumentRoot /var/www/tracks-devel/public
- ServerName tracks.example.org
- ServerSignature On
- LogLevel warn
- ErrorLog /var/log/apache2/error.log
- CustomLog /var/log/apache2/access.log combined
- AddHandler fcgid-script .fcgi
- DefaultInitEnv RAILS_ENV production
- <Files *.fcgi>
- SetHandler fcgid-script
- Options ExecCGI +FollowSymLinks
- </Files>
- <Directory /var/www/tracks-head/public>
- RewriteEngine on
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule ^/(.*) dispatch.fcgi [QSA,L]
- </Directory>
- </VirtualHost>
Comments
#1 Pratik (http://m.onkey.org)
#2 Sander Marechal (http://www.jejik.com)
#3 Brett (http://www.braineak.com/category/programming)
#4 Sander Marechal (http://www.jejik.com)
I'm a PHP developer. No way I am removing libapache2-mod-php5 from my servers :-) Perhaps it is possible to build Passenger from source against apache2-mpm-prefork, but I haven't tried that (yet).
#5 Anonymous Coward
sudo apt-get install zlib1g-dev;
sudo apt-get install build-essential;
sudo apt-get install git-core;
sudo apt-get install mysql-server mysql-client
sudo aptitude install libmysql++-dev libmysqlclient15-dev checkinstall
sudo apt-get install apache2-mpm-prefork
sudo apt-get install apache2-prefork-dev
wget http://www.openssl.org/source/openssl-0.9.8i.tar.gz
tar xzf openssl-0.9.8i.tar.gz
cd openssl-0.9.8i/
./config
make
sudo make install
cd
wget http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p286.tar.gz
tar xzf ruby-1.8.6-p286.tar.gz
cd ruby-1.8.6-p286
./configure --with-openssl-dir="/usr/local/ssl/"
make
sudo make install
cd
sudo apt-get install libopenssl-ruby;
wget http://rubyforge.org/frs/download.php/43985/rubygems-1.3.0.tgz
tar zxf rubygems-1.3.0.tgz
cd rubygems-1.3.0
sudo ruby setup.rb
cd
wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8.1.tar.gz
tar xzf sphinx-0.9.8.1.tar.gz
cd sphinx-0.9.8.1
./configure
make
sudo make install
sudo gem install mysql
sudo gem install rails
sudo gem install capistrano
sudo gem install passenger
sudo passenger-install-apache2-module
==add to apache.conf==
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.0.3
PassengerRuby /usr/local/bin/ruby
sudo /etc/init.d/apache2 restart
#6 Sander Marechal (http://www.jejik.com)
#7 Chris
One thing I found was that your Vhost configuration (while more restrictive than mine thus more secure) didn't seem to like tracks on my server. I ended up going with a old trusty one. I suspect it had to do with the Options allow only happening on .fcgi maybe?
Anyway, nice work on the guide. Was a life saver :)
-Chris
#8 kaner (http://kaner.strace.org)
Alias /tracks /var/www/tracks-devel/public
HTH,
kaner
#9 Anonymous Coward
1 root@box /var/gtd/tracks # RAILS_ENV=production rake db:migrate :(
(in /var/gtd/tracks)
rake aborted!
no such file to load -- spec/rake/spectask
/var/gtd/tracks/Rakefile:10
(See full trace by running task with --trace)
1 root@box /var/gtd/tracks #
#10 Sander Marechal (http://www.jejik.com)
#11 Robin Mitra (http://www.robinmitra.com)
In the meantime, to the mod_rail users, what's the benefit of using mod_rail instead of mod_fcgid? How does the performance compare?
#12 Sander Marechal (http://www.jejik.com)
#13 Robin Mitra (http://www.robinmitra.com)
I followed your guide and installed Tracks. I could open up the page to signup for an account on Tracks, but after that I get this error:
"Application error (Apache)
Change this error message for exceptions thrown outside of an action (like in Dispatcher setups or broken Ruby code) in public/500.html"
Is this the error you mentioned near the top of the guide?
My version of Tracks is 1.7, as you suggested. Did you install version 1.7 or 1.7RC/RC2?
#14 Robin Mitra (http://www.robinmitra.com)
chown www-data:www-data -R /var/www/tracks-devel
Also, I noticed that uncommenting subdir:"/tracks" in site.yml and changing it to "/tracks-devel" (or even keeping it as "/tracks") caused problems accessing CSS files needed for styling page.
BTW, there is a typo in your article: <Directory /var/www/tracks-head/public> should be <Directory /var/www/tracks-devel/public>
Thanks alot for this tutorial, you saved me from relying on bitnami's stack install, which really was an overkill for just one application.
#15 Sander Marechal (http://www.jejik.com)
#16 Colin Mollenhour (http://colin.mollenhour.com)
sudo chmod -R a+rX /usr/lib/ruby
Comments have been retired for this article.