How to install Tracks on Debian Lenny with Apache mod_fcgid
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.
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
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
SetHandler fcgid-script
Options ExecCGI +FollowSymLinks
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.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*) dispatch.fcgi [QSA,L]
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!
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
SetHandler fcgid-script
Options ExecCGI +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*) dispatch.fcgi [QSA,L]
Source: http://www.jejik.com/
Related Posts
Tags: apache, Apache mod_fcgid, Debian Lenny, Ruby on Rails and mod_fcgid
Viewed: 151 views

















