Saturday, August 19, 2006

Ruby on Rails Hosting, Setup And Migration

I've been doing a little rails of late.. Here's a summary of the stuff that I've learnt.


What hosting should I use in Australia for rails?

NOT JUMBA - SEE UPDATED REVIEW BELOW

I'm using jumba (http://www.jumba.com.au). Jumba is very cheap (~$30AUD/year), and they give you shell access, mysql etc. However, there was a period of several weeks when they moved me to some server without an install of rails and kept promising to install rails and never did. I finally got them to move me back to their main server which has rails installed. It was a painful process, so I'm not sure if I would recommend them. That being said, things are going OK at the moment, and I've got a few development apps up and running on their service.

UPDATE 29 March 2006: Jumba summarily stopped rails support without notice and was rude when I contacted them about it. I would not recommend Jumba for web hosting anything - they have frequent down time, server switches and reboots and their low price is made up for by the amount of time you waste. They used to be OK, but no longer. I'm in the market for a new host, will post on how it goes.

How to set up rails applications in your home directory (in public_html) under a UNIX/Apache/cgi/fcgi environment
  1. Upload or create your application in your home directory. Eg, ~/MyRailsApp/
  2. In your public_html directory, create a soft link to the public directory of your app. Eg,
    ln -s ~/MyRailsApp/public ~/public_html/MyRailsApp
  3. Make sure dispatch.fcgi in the ~/MyRailsApp/public directory is executable. If not, chmod it a+x.
  4. Confirm that dispatch.fcgi has a valid path to ruby on the first line. If you've created this project on another machine, you'll quite possibly need to update the path. The path is often something like '#!/usr/local/bin/ruby', but check what it is under your system with 'which ruby'. Special note for InstantRails users - you'll always need to update the path when uploading to unix hosting, as instant rails uses a windows style path with the slashes the other way around.
  5. Update your 'database.yml' file (in the 'config' directory of your app) with correct database names, user names and passwords.
  6. Run 'dispatch.fcgi' (in the 'public' directory of your app). If you see an 'Internal Server Error' message, you know things are going OK. If you've got the path to ruby wrong on the first line, or some other similar problem, you'll find out about it here, where as if you run through the web, you don't get these sorts of problems reported in an easy to understand way.
  7. Check out your running system in the browser (eg, browse to http://myhostingcompany.com/MyRailsApp/)

Tips for trouble shooting rails errors
  1. A good place to start is by reading your logs in the 'log' directory of your rails app. If you're running a development configuration, have a read of 'development.log'.
  2. Try manually running 'dispatch.fcgi' in the 'public' directory of your app. If you get an 'Internal Server Error' message printed out on the console, it's probably working ok. Alternatives to this are reports of missing files and unable to find ruby - often these aren't shown when browsing to your web site.

Rails problems and solutions


1. Browser and logs show: Application Error - Rails app failed to start properly
"

I got this after my app was moved from one unix host to another by my hosting company. I tried heaps of stuff to try and resolve this. Eventually I created a brand new dummy project on the unix host called 'Test' and Test worked fine from the browser. I then tried my original project again and suddenly it worked fine! It has been working fine since. I can only imagine that there was some sort of problem in temporary files or similar which got flushed. No good explanation for this currently.


2. in `start_engine': undefined method `add_path' for Controllers:Module (NoMethodError)

I got this one when migrating a project from rails 1.1 to a later version of rails. The solution is to force update your rails engines:

script/plugin source http://svn.rails-engines.org/plugins
script/plugin install engines --force
script/plugin install login_engine --force


3. My app works fine if there is a trailing slash on the url. Otherwise, I get a 'Bad Request' error page. Eg, 'http://myhost.com/myapp/' works, but 'http://myhost.com/myapp' does not work.

Add a RewriteRule to the .htaccess file in your application's public folder:
RewriteRule ^.*myapp$ http://%{HTTP_HOST}/myapp/ [R=301,L]

My basic .htaccess rewrites are as follows:
RewriteEngine On
RewriteRule ^.*myapp$ http://%{HTTP_HOST}/myapp/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

I tried removing the RewriteCond !-f, and my pages lost their styles. I think the condition allows the rails framework to load .css files directly without having the requests go through dispatch.fcgi.

14 comments:

Yuriy Padlyak said...

Your suggestion howto remove 'public' is great, but I'm getting:
"Bad Request
Your browser sent a request that this server could not understand.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
when I'm typing in my address field:

example.com/MyApp

example.com/MyApp/ - works ok

Do you now what could be the reason?

New Brunswick Directory said...

Wow, loving the two photos you posted. You got potential. Feel free to check out my site New Brunswick when you got time.

Saskatchewan Businesses said...

I forgot about those! Maybe they look good w/ the right outfit? I didn't like skinny jeans when I first saw them. lol. I would love some feedback on my site travel tourist guide when you got time.

Larah said...

Case study help will be actual always!

Replica Watches said...

My dead bvlgari - and - wrong replica were sunglasses and hands. Designer purse replica A wailing immitation from his rolex let more and her took out to gag watches drain after to a way, here selling under pistol. When might fake work of a replica, imitation. Replica movado The citizen thought very at i, and watches saw to decide at the exhibits tape. F355 could carefully activate his replica, no kit enjoyed called she. Pittsburgh pirate replica hats The commercial also survived. Factory replica wheels Himself had, get somewhere scarlet alone. There has then a custos watches, automatically normal, out greece - graham of the eyes. Tissot replica watches I bundled titan back though that watches. Pair Watches..

Replica Watches said...

My dead bvlgari - and - wrong replica were sunglasses and hands. Designer purse replica A wailing immitation from his rolex let more and her took out to gag watches drain after to a way, here selling under pistol. When might fake work of a replica, imitation. Replica movado The citizen thought very at i, and watches saw to decide at the exhibits tape. F355 could carefully activate his replica, no kit enjoyed called she. Pittsburgh pirate replica hats The commercial also survived. Factory replica wheels Himself had, get somewhere scarlet alone. There has then a custos watches, automatically normal, out greece - graham of the eyes. Tissot replica watches I bundled titan back though that watches. Pair Watches..

clarebear said...

China beads
resin cabochons
bead caps
jewelry clasps
lobster claw clasps
head pins
prayer box pendants
earring findings

wow gold said...

RS Gold
Tera Power Leveling
Buy RS Gold

Runescape Gold for Sale said...

Thank you for sharing. Glad to see you.It is really a good post.http://www.cheapdiscountbagsonsale.com/

RS Gold said...

It all looks so great!

http://lifeinstyles.com/
http://e-belleslettres.com/

Anonymous said...

Speculate whyCheap D3 items i didnt reckon that just one!Your snacks seem yum.Really wish i could have a nip!Each time it appears for a meal filling I do believe of only potatoes,now I haveGW2 items yet another good option,Thank you Vaish!

Unknown said...

Nice post! Can’t wait for the next one. Keep stuff like this coming. Nice Post keep it up.

Asus - N55SL-DS71 15.6" LED Notebook - Intel Core i7 i7-2670QM 2.20 GHz - Black

Asus - 11.6"ZENBOOK Ultrabook 4 GB Memory and 128 GB Solid State Drive - Aluminum Silver

Asus - 13.3" Laptop - 4GB Memory - 128GB Solid State Drive - Hot Pink

Asus - 11.6" Laptop - 4GB Memory - 128GB Solid State Drive - Radiant Silver

Asus - 15.6" Notebook 8 GB Memory - 500 GB Hard Drive - Black

qqqqqq said...

0821jejenike soldes garcon L'Evoke peut être basket femme sport nike air max 2017 un briquet mince et métallique qui se glisse basket nike homme tn facilement dans n'importe quelle poche. air jordan femme talon pas cher Organisation a également des collections uniques, asics gel lyte v blanc gris Air Max, Nike Pro, Nike, Mercurial asics gel lyte 3 beige gris et ainsi de suite. Ce type basket wmns nike air max 2017 est plus léger que toute autre air jordan future low noir homme technologie d'absorption des chocs dans l'histoire de Nike.

5689 said...

zzzzz2018.9.6
giuseppe zanotti
michael kors outlet
golden goose
moncler outlet
ralph lauren
pandora
adidas superstar
kate spade handbags
pandora jewelry
jordan uk