Installing Tracks on Ubuntu
I've installed the Rails task tracker Tracks in my Rails server, running Apache2, Passenger, and MySQL on Ubuntu 8.04. There were a couple of changes that I needed to do to make it all work.
Most of these notes are shamelessly cribbed from the TJN blog post.
Install Rails on the server
This process is described on a separate Ruby on Rails installation page.
Create the database and user
- As per the normal production environment step, create the necessary database and user.
root@server:~# mysql -u root -p mysql> create database tracks; mysql> grant all on tracks.* to 'tracksuser'@'localhost' identified by 'SecretPassword'; mysql> quit;
- We can also create a user that Tracks runs as
root@server:~# adduser tracks
Install the files
- Download Tracks from the Tracks homepage and copy the file into
/var/www/tracks.domain.tld
. - Unzip the files
root@server:~# cd /var/www/tracks.domain.tld root@server:/var/www/tracks.domain.tld# unzip tracks-1.7.zip root@server:/var/www/tracks.domain.tld# cd tracks-1.7
- Now, fix the ownership and permissions of the files
root@server:/var/www/tracks.domain.tld/tracks-1.7# chown -R tracks:tracks * root@server:/var/www/tracks.domain.tld/tracks-1.7# chmod -R 664 * root@server:/var/www/tracks.domain.tld/tracks-1.7# find -type d -exec chmod a+x '{}' \; root@server:/var/www/tracks.domain.tld/tracks-1.7# chmod -R a+x script/*
Update the Tracks configuration
- Edit
config/database.yml
to use the MySQL database:
production: adapter: mysql database: tracks host: localhost username: tracksuser password: SecretPassword
- Edit
config/site.yml
to change the password salt:
# This is the 'salt' to add to the password before it is encrypted # You need to change this to something unique for yourself # salt: "change-me" salt: "SecretSalt"
- (substitute your own salt, of course)
Populate the database
root@server:/var/www/tracks.domain.tld/tracks-1.7# rake db:migrate RAILS_ENV=production
Allow recurrent todos
Modify line 76 of app/views/recurring_todos/_recurring_todo_form.erb
to be this:
text_field(:recurring_todo, :start_from, "value" => format_date(Time.now), "size" => 12, "class" => "Date", "onfocus" => "Calendar.setup", "tabindex" => 6, "autocomplete" => "off") %>
- (instead of a reference to
format_date(Time.today)
)
Create the Apache virtual host
- Create the virtual host file,
/etc/apache2/sites-available/tracks.domain.tld
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/tracks.domain.tld/tracks-1.7/public ServerName tracks.domain.tld RewriteEngine On RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f RewriteCond %{SCRIPT_FILENAME} !maintenance.html RewriteRule ^.*$ /system/maintenance.html [L] ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly" <DirectoryMatch "^/.*/\.svn/"> ErrorDocument 403 /404.html Order allow,deny Deny from all Satisfy All </DirectoryMatch> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On </VirtualHost>
- Remove Tracks's
.htaccess
file:
root@server:var/www/tracks.domain.tld/tracks-1.7# mv public/.htaccess public/dontneedhtaccess
- Enable the site:
root@server:~# a2ensite tracks.domain.tld root@server:~# /etc/init.d/apache2 reload
Allow restarts of Passenger
- Create the
tmp
directory:
root@server:~# mkdir -p /var/www/tracks.domain.tld/tracks-1.7/tmp
- To restart Passenger, issue this command:
root@server:~# touch /var/www/tracks.domain.tld/tracks-1.7/tmp/restart.txt