The Endless Knot

Life, Buddhism, and Me

13 March 2007

WestHost Rails application deployment — What I’ve learned

After many days of frustration, my Rails app is up and running on our WestHost server. Getting the app uploaded was not so bad, but it appears that you simply can’t do it with Capistrano because SVN is not one of the installable applications on WestHost. I really didn’t want to load up gcc and install SVN by hand. But when I did try out Capistrano, it did partially upload my app — it populated the database!

What do you need to know to get your rails app running on WestHost? Here’s what I learned:

Just FTP it

Since Capistrano was looking like it would be an ordeal, I just decided to roll up the app in a tarball and upload it to the host by ftp. That worked well, and I added an Alias in httpd.conf so that the server would see the new Rails directory. I also updated the .htaccess in the apps Public folder, all as described in the Rails wiki entry HowtoDeployMoreThanOneRailsAppOnOneMachine.

#!/usr/bin/env ruby in the scripts doesn’t work

WestHost doesn’t have a copy of env in /usr/bin, so that little bit of portability is broken. I had to go through and change all the scripts to start with #!/usr/local/ruby/bin/ruby instead. I tried creating a symlink to env in /usr/bin, but it didn’t work. I probably did it wrong (prolly shoulda been a hard link), but didn’t feel like messing around with it any more, and I had already changed the scripts to use the new shebang.

Basic HTTP Authentication is different for Apache

I followed The Teenage Mutant Ninja Hero Coders method to get basic authentication in my app. When I was first doing development on my Mac with lighttpd, all was swell. Then after deploying, I couldn’t figure out why I couldn’t log in. Well, it was my ignorance of the part on the above page that says “If you are using Apache and mod_fastcgi, this method will likely not work out of the box.” After playing around, I edited my httpd.conf to look like this:

<IfDefine HAVE_FASTCGI>
AddModule mod_fastcgi.c
# Added the following line to allow
# passing of http headers to fcgi
FastCgiConfig -pass-header Authorization
</IfDefine>

Ta da! Authentication works!

Still to do

I think I have some routing issues. I have to access the app by doing http://www.server.com/appname/appname/. Actually, I think I need to play with the RewriteBase or something. And, if I leave off the trailing slash, the images used by the app don’t load.

Other than that, the app appears to be working well. I can do all the things with this basic app that I’m supposed to be able to do. All the CRUD stuff is working. All the goodies I put in, since it was so easy, are working too, like webcal:// calendar subscription and CSV export of the data.

I do want to change my report printing from just javascript prints to using PDF::Writer for more control over pagination. That shouldn’t be too hard now that the basic app is running.

The only big issue is normalizing the app so that it’s the same on the production server and the Mac I’m developing on. I think the biggest problem is the shebangs in the scripts folder. I think the best thing is to get env in /usr/bin so I can use that portable method of invoking Ruby.

As I get farther, I’ll post updates. I hope this helps anyone who comes across this, and who is deploying to WestHost.

lotus dingbat

0 Comments:

Post a Comment

<< Home

© 2006 Simon Nolan


The End