Oh this has been such a pain. I've been fighting and fighting trying to get Tracks which is a Ruby On Rails project working correctly on FreeBSD 7.0 with Apache 2.2.x with no luck. I finally gave up Apache and tried lighttpd. Within about 30 minutes it was all working.

So here's my instructions. But first a couple of notes:

1) I already had Apache22 installed on this machine. I deinstalled the various package (such as MySQL, Apache22, rubygem, etc) and tried to remove all remnants but I may have missed something. So if a directory doesn't exist on your system that I mention or other weird things show up then let me know and I'll update my docs. If you have any suggestions for improvements or changes let me know.

2) I'll be putting 'testing' as a password throughout this. Please use a proper secure password wherever you see 'testing'.

3) USE AT YOUR OWN RISK This installation is being done on a machine on my private LAN behind a firewall. I do not guarantee that this system is secure in the slightest. If these instructions blow up your machine, give you brain tumors or cause you to suddenly like New Kids on the Block don't blame me!

If you agree with the above then let's get started...here's my instructions....

I already had the ports collection updated to the latest version.

Prerequisites

Unzip
# cd /usr/ports/archivers/unzip
# make install clean

WGET
# cd /usr/ports/ftp/wget
# make install clean

MySQL Server Install
# cd /usr/ports/databases/mysql51-server
# make install clean
# echo 'mysql_enable="YES"' >> /etc/rc.conf
# /usr/local/etc/rc.d/mysql-server start
# mysql -uroot

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.1.23-rc FreeBSD port: mysql-server-5.1.23

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
>connect mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Connection id: 2
Current database: mysql

mysql> delete from user;
Query OK, 5 rows affected (0.00 sec)

mysql> grant all privileges on *.* to sqladmin@localhost identified by 'testing' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> create database tracks15;
Query OK, 1 row affected (0.01 sec)

mysql> grant all privileges on tracks15.* to tracksadmin identified by 'testing' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

What we did above is to delete the default root user with no password and create the 'uber' mysql user - sqladmin with a password of testing then created a database called tracks15 with an account called tracksadmin to access the new tracks database.

Ruby On Rails Install

# cd /usr/ports/www/rubygem-rails
Select the FCGI option. Don't bother with MEMCACHE_CLIENT
# make install clean

# cd /usr/ports/www/rubygem-redcloth
# make install clean

# cd /usr/ports/ww/rubygem-mongrel
# make install clean

Lighttpd Install

# cd /usr/ports/www/lighttpd/
# make install clean

Deselect IPV6.
The only option you should see is OpenSSL (not really needed at this point but what the hell.

# echo 'lighttpd_enable="YES"' >> /etc/rc.conf
# mkdir -p /usr/local/www/data
# echo 'HELLO. IT WORKS' > /usr/local/www/data/index.html
# nano +43 /usr/local/etc/lighttpd.conf

Change

server.errorlog = "/var/log/lighttpd.error.log"
to
server.errorlog = "/var/log/lighttpd/lighttpd.error.log"

Down at about line 119
Change

accesslog.filename = "/var/log/lighttpd.access.log"
to
accesslog.filename = "/var/log/lighttpd/lighttpd.access.log"

# mkdir /var/log/lighttpd
# chown www:www /var/log/lighttpd

Point your web browser to your IP and you should see 'HELLO. IT WORKS. If it doesn't then check the logs and fix it before continuing.

Tracks Install

# cd /usr/local/www/data
# wget http://www.rousette.org.uk/projects/files/tracks-1.5.zip
# unzip tracks-1.5.zip
# mv tracks-1.5 tracks/config
# nano database.yml

Change

production:
adapter: sqlite3
database: db/tracks-15-blank.db

to

production:
adapter: mysql
database: tracks15
username: tracksadmin
password: testing
socket: /tmp/mysql.sock

Comment out development and test sections to avoid problems later.

# nano environment.rb

Change:
SALT = "change-me"
to
SALT = "testing"

Uncomment and change:
# ENV['TZ'] = 'US/Eastern'
to
ENV['TZ'] = 'America/Vancouver'

# cd /usr/local/www/data/tracks/db/
# rake db:migrate RAILS_ENV=production
# cd ..
# ruby script/server webrick -e production

Point your web browser to your IP address on port 3000. (http://x.x.x.x:3000)

Type in your desired username and password for the web interface. Now you can do some testing and check that things are working fine.

Go back to the command line and hit CTRL+C to stop webrick.

# cp /usr/local/www/data/tracks/config/lighttpd.conf /usr/local/etc/
# nano /usr/local/etc/lighttpd.conf

Change:
server.port = 3000
to
server.port = 80

server.modules = ( "mod_rewrite", "mod_accesslog", "mod_fastcgi", "mod_compress", "mod_expire" )
to
server.modules = ( "mod_rewrite", "mod_accesslog", "mod_fastcgi", "mod_compress", "mod_expire", "mod_redirect" )

server.pid-file = CWD + "/tmp/pids/lighttpd.pid"
to
server.pid-file = "/var/run/lighttpd.pid"

server.document-root = CWD + "/public/"
to
server.document-root = "/usr/local/www/data/tracks/public/"

server.errorlog = CWD + "/log/lighttpd.error.log"
to
server.errorlog = "/var/log/lighttpd/lighttpd.error.log"

accesslog.filename = CWD + "/log/lighttpd.access.log"
to
accesslog.filename = "/var/log/lighttpd/lighttpd.access.log"

fastcgi.server = ( ".fcgi" => ( "localhost" => (
"min-procs" => 1,
"max-procs" => 1,
"socket" => CWD + "/tmp/sockets/fcgi.socket",
"bin-path" => CWD + "/public/dispatch.fcgi",
"bin-environment" => ( "RAILS_ENV" => "development" )
) ) )

to

fastcgi.server = ( ".fcgi" => ( "railsapp" => (
"min-procs" => 1,
"max-procs" => 5,
"socket" => "/tmp/fcgi.socket",
"bin-path" => "/usr/local/www/data/tracks/public/dispatch.fcgi",
"bin-environment" => ( "RAILS_ENV" => "production" )
) ) )

/usr/local/etc/rc.d/lighttpd start

Point your web browser to your newly working Tracks server.