"Any soldier worth his salt should be antiwar. And still there are things worth fighting for."
The new site is runing ruby on rails, and this column is an attempt to document what I did and how I did it. For posterity, and in case it might help anyone else who may be doing the same thing.
I started at home with my developement environement. It’s on OS X, running PostgreSQL and the latest version of Rails. I’ve used the following gems:
I was able to compile, install and run everything fairly easily, if you need a hand with OS X specifically take a look at the guide on Apple’s site.
Armed with Agile Web Development with Rails and also a few helpful resources on the web:
I was able to prototype this web site with just the functionality I wanted. No more, no less. I transferred the data from my old site and went through several rounds of testing to make sure everything worked the way I wanted it to.
The next step was getting it all hosted. There are all kinds of choices, but I went with RIMUhosting and their low end Virtual offering. Why RIMU? Well, after some research into good hosting companies for Rails apps, they kept coming up with glowing reports. Looking at the service they offered, it had everything I wanted and the price was just a little more expensive than my current host but with the benefit that I would be in total control. So I jumped in with their low end virtual hosting option. Given that my site doesn’t see a whole lot of traffic, that should do me just fine. I went with Debian in the load, and within a couple hours they had the basic server setup for me.
Next I had to modify the basic configuration to suit me. I borrowed a lot from The Perfect Rails/Debian/Lighttpd Stack. That would get me Ruby, Rails, Lighttpd, FastCGI and Subversion. I excluded the Postfix installation as mail for my domains is handled through my Name Registrar. At some point in the future I may add it, but one step at a time.
I did have to do some compiling on my own. Some of the apps I wanted to use aren’t in Debian Sarge at the version I wanted to use. For the sake of simplicity I wanted to keep version the same as my development environemnt. Debian gets a lot of good reviews for stability, but that comes at the price of being slow to adopt new software revisions. That’s not a big deal though, I downloaded the sources and compiled what I needed:
Now I did have a couple of issues that popped up, the biggest of which was that ‘flex’ was not installed into my Debian environment by default. This didn’t cause me any problems until I was trying to import my postgresql database into the new server. For some reason it wouldn’t import one of the tables or any of the functions that were defined. After some digging I discovered I forgot to compile and install the tsearch2 module for postgresql.
This is where the flex issue came up. Tsearch2 requires flex in order to compile. Because it wasn’t installed when I compiled Postgres, the compile for tsearch2 was failing. No big deal, just install flex right? Wrong.
After much searching for similar problems, I finally found the solution. When you run ‘make’ in the tsearch2 directory, it references the makefile.global options for postgres. Becaused postgres didn’t see flex, it didn’t set the option and thus tsearch2 wouldn’t compile even after I had installed flex. The solution is to add the path to flex in the makefile.global inside the ‘src’ directory of your postgresql directory. Once that was set I was golden. Compiling and installing were a breeze.
The only other significant issue I faced was with some of the gems I wanted to use, in particular rmagick and postgres. Because I was using newer version of software, installed in non-standard locations, I had to execute gem with the paths to the include files, for example:
gem install postgres -- --with-pgsql-include=/usr/local/pgsql/include --with-pgsql-lib=/usr/local/pgsql/lib
Once I added the right paths, the gems installed and away I went.
The only other bit I spent some time fidling with is capistrano. This tool alows me to do development and make changes on my laptop. When I’m satisfied it all works, a simple ‘rake deploy’ takes the latest version from subversion, deploys it onto the web server, and restarts the fastcgi processes. Making changes to the web site couldn’t be easier.
Hopefully this is helpful to those trying to do the same thing. As always, what’s here may not apply exactly to your situation. Be flexible, willing to learn, and you’ll eventually get it.
Update: While testing my production site before moving the DNS entries, I did run into a big problem with RMagick. I use this gem only when uploading photos so they get resized automatically. However I kept getting an error when I tried to upload a picture:
Uninitialized const ‘Magick’
Again there was much search of the web and to be honest I still don’t quite understand the problem. When I do a ‘gem install rmagick’ everything seems to run just fine, but the RMagic.so file doesn’t go where I would expect it.
The final solution was to download the source, compile and install into /usr/local/lib/site_ruby and then add an evnironement variable to my fastcgi declaration in lighttpd.conf:
'LD_LIBRARY_PATH' => '/usr/local/lib'
After restarting lighttpd, everything worked as it should. I’m still stumped about what happened here, as I didn’t have any problems installing the gem on OS X. Unfortunately I don’t have the time to investigate it any further.