One of the first things I'm trying to get going in 2007 is a way to be more productive while at the same time not losing my mind with all the stuff I have to do, which is the mental state that I'm in right now. I just finished reading a fantastic book on the subject, Getting Things Done, and have decided to get started with it. One of the key concepts of the approach is to have a place where all your projects and tasks are stored, and for me, it makes sense that that place be an electronic one.
I tried getting the GTD template for Lotus Notes going since I use Lotus Notes at work, but it didn't work out for me since I'm using a pre-Beta of the next version of Notes, Hannover, and I'm experiencing unrelated problems at the moment. I did some searching and found an application called Tracks that also might be able to help me out. I thought it was interesting because I had heard about it before and it was also based on Ruby on Rails, the so-called latest and greatest web development platform.
As it turns out, my first experience with Ruby on Rails has been pretty much brutal. As with all things geek-related, it's hard to install and use. Below what I did to get it going on my Fedora Core 4 web server, but VMMV. For the record, this document assumes you already have Apache and MySQL installed and running.
-
Get Tracks and prepare it and your database
I started with the installation manual and tried following the steps. First, download Tracks and unzip it where you want it to be stored. In my case, I'm keeping it in
/srv.I like to make the whole folder owned by the webserver:[root@eloise]# cd /srv [root@eloise srv]# wget http://www.rousette.org.uk/projects/files/tracks-1.043.zip [root@eloise public]# unzip tracks-1.043.zip
Next, get your database set up.[root@eloise srv]# chown -Rf apache:apache tracks-1.043
Copy the file[root@eloise srv]#mysql -u root -p mysql> CREATE DATABASE tracks104; mysql> GRANT ALL PRIVILEGES ON tracks104.* TO yourmysqluser@localhost \ IDENTIFIED BY 'password-goes-here' WITH GRANT OPTION;config/database.yml.tmpltoconfig/database.yml,config/environment.rb.tmpltoconfig/environment.rbandlog.tmpltolog.Open the[root@eloise srv]# cd /srv/tracks-1.043/config [root@eloise config]# cp database.yml.tmpl database.yml [root@eloise config]# cp environment.rb.tmpl environment.rb [root@eloise config]# cd .. [root@eloise tracks-1.043]# cp -rf log.tmpl log
config/database.ymlfile, and enter your username and password details for the database you just set up under the 'production' and 'development' sections.Open the file config/environment.rb and look at the last line which should read: SALT = "change-me". Change the word change-me to something else of your choosing.[root@eloise tracks-1.043]# vi config/database.yml
It's at this point that the default instructions pretty much fall apart for us Fedora Core users.[root@eloise tracks-1.043]# vi config/environment.rb
-
Install Ruby and put it on Rails
I found a great part of the well-written guide Installing Ruby on Rails with Lighttpd and MySQL on Fedora Core 4 that really helped me out. A lot of the steps below are based on it, except I am using Apache and not Lighttpd.
First, install the necessary libraries:
Looks simple, doesn't it? Well ... surprise! It's not! Now you have to download the "Ruby" platform installer and do a bunch of stuff from there:[root@eloise]# yum install ruby ruby-libs ruby-devel irb rdoc
You should see a message like this:root@eloise]# cd /tmp root@eloise tmp]# wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz [root@eloise tmp]# tar -zxvf rubygems-0.9.0.tgz [root@eloise tmp]# cd rubygems-0.9.0 [root@eloise rubygems-0.9.0]# ruby setup.rb
Now you can clean up and install Rails:Successfully built RubyGem
You should receive a message indicating that rails has been installed successfully.[root@eloise rubygems-0.9.0]# cd .. [root@eloise tmp]# rm ruby* -drf [root@eloise tmp]# gem install rails --include-dependencies
-
Set up Tracks
Here's where we continue with the installation manual. It says to execute the following command in your tracks installation folder:
Unfortunately for us, it's probably going to fail with a message similar to this:[root@eloise tracks-1.043]# rake migrate
I had a look at the Debian installation guide and it had the fix there. What you need to go is edit theNo such file or directory - /tmp/mysql.sock
database.ymlfile again and add a reference for the MySQL socket file, which is in a different location in Fedora.What you want to do is add a "socket" line as follows for your development and production environments:[root@eloise tracks-1.043]# vi config/database.yml
Then, you can execute the migrate command again:development: adapter: mysql database: tracks104 host: localhost username: yourdbusername password: yourdbpassword socket: '/var/lib/mysql/mysql.sock' production: adapter: mysql database: tracks104 host: localhost username: yourdbusername password: yourdbpassword socket: '/var/lib/mysql/mysql.sock'
Unfortunately (again), it's probably going to fail with a different error message:[root@eloise tracks-1.043]# rake migrate
Now, I'm not sure what I did to resolve this, but I think the basic thing was that there is some kind of version compatibility in the way MySQL stores privileges or passwords because of an upgrade I did in the past or something. I did a few things to get it going. First, I edited the[root@eloise tracks-1.043]# rake migrate (in /srv/tracks-1.043) rake aborted! Mysql::Error: Lost connection to MySQL server during query: SELECT version FROM schema_info (See full trace by running task with --trace)
/etc/my.cnffile and changed theold_passwordsline:I commented out the previous line and created a new one with a different value:[root@eloise tracks-1.043]# vi /etc/my.cnf
That didn't seem to work so I tried to flush the privileges:#old_passwords=1 old_passwords=0
That didn't seem to work either so I executed a script that tries to resolve the problem:[root@eloise tracks-1.043]# mysql -u root -p mysql> flush privileges; mysql> exitI restarted:[root@eloise tracks-1.043]# mysql_fix_privilege_tables --password=yourdbpassword
Now I decided to overwrite the password for my database user just to make sure it was stored correctly:[root@eloise tracks-1.043]# /sbin/service mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ]
I restarted and ran the script again, this time it seemed to work:[root@eloise tracks-1.043]# mysql -u root -p mysql> SET PASSWORD for tracks@localhost=PASSWORD('yourdbpassword'); mysql> exit[root@eloise tracks-1.043]# /sbin/service mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ] [root@eloise tracks-1.043]# rake migrate
-
Set up Apache
To get it going in Apache, the easiest way is to create your own app-specific configuration file:
Populate it as follows:[root@eloise tracks-1.043]# vi /etc/httpd/conf.d/tracks.conf
You will notice that I used an alias because that's just how I roll. If you use an alias, you will have to modify theAlias /youraliasname/ "/srv/tracks-1.043/public/" <Directory /srv/tracks-1.043/public/> Options ExecCGI FollowSymLinks AllowOverride all Allow from all Order allow,deny </Directory>.htaccessfile accordingly.Add this line around where the comments tell you to:[root@eloise tracks-1.043]# vi public/.htaccess
RewriteBase /youraliasname
The application should now be available for you to access at
http://yourservername/youraliasname. That doesn't mean you can use it, though, 'cause it will probably be horribly slow!To try to fix this, you can change the environment to "production". By default, it's set to "development" which has a bunch of debugging stuff on that you don't need. To change it, edit the
environment.dbfile:Change the environment by changing the line as follows:[root@eloise tracks-1.043]# vi config/environment.rb
ENV['RAILS_ENV'] = 'production'
Now that you've tried again, you'll probably notice that it's still super slow. In that case, there's even more work to be done!
-
Improve performance (slightly) with FastCGI
First, you need to install the FastCGI development libraries and the Ruby FastCGI bindings.
[root@eloise tracks-1.043]# cd /tmp [root@eloise tmp]# wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz [root@eloise tmp]# tar -zxvf fcgi-2.4.0.tar.gz [root@eloise tmp]# cd fcgi-2.4.0 [root@eloise fcgi-2.4.0]# ./configure [root@eloise fcgi-2.4.0]# make [root@eloise fcgi-2.4.0]# make install [root@eloise fcgi-2.4.0]# cd .. [root@eloise tmp]# rm fcgi* -drf
[root@eloise tmp]# wget http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz [root@eloise tmp]# tar -zxvf ruby-fcgi-0.8.6.tar.gz [root@eloise tmp]# cd ruby-fcgi-0.8.6 [root@eloise ruby-fcgi-0.8.6]# ruby install.rb config [root@eloise ruby-fcgi-0.8.6]# ruby install.rb setup [root@eloise ruby-fcgi-0.8.6]# ruby install.rb install [root@eloise ruby-fcgi-0.8.6]# cd .. [root@eloise tmp]# rm ruby-fcgi-0.8.6* -drf
Now you need to get it going with Apache. I found a guide called Red Hat Enterprise Linux 4 + RT 3.4.2 + FastCGI 2.4.2 Install Guide that helped me get through figuring out how to install this. In order to compile the needed Apache module, you have to download the Apache development kit:
Then, download and extract the module source:[root@eloise public]# yum install httpd-devel
You'll need to edit some files before you can compile.[root@eloise tmp]# wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz [root@eloise tmp]# tar -xzvf mod_fastcgi-2.4.2.tar.gz
Change this line as follows to match up with the Fedora environment:[root@eloise tmp]# cd mod_fastcgi-2.4.2 [root@eloise mod_fastcgi-2.4.2]# cp Makefile.AP2 Makefile [root@eloise mod_fastcgi-2.4.2]# vi Makefile
Then you can compile, install, and clean up:top_dir = /etc/httpd
You need to make some directories available to the module for it to use:[root@eloise mod_fastcgi-2.4.2]# make [root@eloise mod_fastcgi-2.4.2]# make install [root@eloise mod_fastcgi-2.4.2]# cd .. [root@eloise tmp]# rm mod_fastcgi* -drf
Now you need to set up the app to use FastCGI. First, edit[root@eloise tmp]# mkdir /etc/httpd/logs/fastcgi [root@eloise tmp]# mkdir /etc/httpd/logs/fastcgi/dynamic [root@eloise tmp]# chown apache:apache /etc/httpd/logs/fastcgi [root@eloise tmp]# chown apache:apache /etc/httpd/logs/fastcgi/dynamic
.htaccessagain:Comment out the existing line below and add your own to point to the[root@eloise tmp]# vi /srv/tracks-1.043/public/.htaccess
dispatch.fcgifile:Now, edit your#RewriteRule ^(.*)$ dispatch.cgi [QSA,L] RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
tracks.conffile:You need to add a line to the top and to the bottom so the file reads as follows:[root@eloise tmp]# vi /etc/httpd/conf.d/tracks.conf
Restart the server:LoadModule fastcgi_module modules/mod_fastcgi.so Alias /youraliasname/ "/srv/tracks-1.043/public/"
Options ExecCGI FollowSymLinks AllowOverride all Allow from all Order allow,deny FastCgiIpcDir /tmp The restart will probably fail with an error like this:[root@eloise public]# /sbin/service httpd restart
I found a bunch of info on this page that helped. You'll need to make a directory that FastCGI just created accessible to it:FastCgiIpcDir /tmp: can't create dynamic directory "/tmp/dynamic": access for se rver (uid -1, gid -1) failed: read not allowed
Now, restart Apache and you should be set![root@eloise public]# chmod 777 dynamic
[root@eloise public]# /sbin/service httpd restart
You now have a fully functioning installation of Tracks that is somewhat fast but probably feels sluggish. You've also just wasted a couple hours of your time. The steps involved to get this going just amazed me. If anyone has any suggestions on a better way to do it, please let me know! What a huge pain in the ass!

