I just tried Sinatra the first time, because it sounded nice and I had
planned to do a smallish project that I'd normally do with Rails, but
wanted to give Sinatra a shot. Implementing the project went OK.
Thanks for a great product!
The problems started when I tried to deploy the application to
production, more accurately said to Bluehost. Bluehost supports Rails,
so it has theoretically all the pieces needed to support Sinatra.
Unfortunately, deploying wasn't so easy in practice and it took me
something like five hours to get it working. So, finally I can say
that it is possible to run Sinatra in Bluehost. There have been some
articles in Sinatra mailing list about the subject of running Sinatra
with fcgi, but they are really old. Also, in Bluehost forums there's
one post of the topic. That however, didn't work for me. So, I'm
posting my experiences to 1) announce that it is possible to get
Sinatra working in Bluehost and 2) make installing Sinatra in Bluehost
less troublesome for anybody else trying.
Here's the gem list I have in Bluehost for refenrence on what kind of
setup I got Sinatra working in Bluehost:
# gem list --local
*** LOCAL GEMS ***
rack (1.2.1, 1.0.1)
Naturally, the essential gems are rack, tilt (I assume Sinatra needs
this) and rack, the rest are for my Rails stuff and my other Ruby
Unfortunately I didn't record my installation steps, so I cannot
provide with a fail-safe step-by-step guide, but I'll share what I
learned in the process and what resources I used to make the magic
There's an article in Bluehost forums with title "Sinatra
Howto) that is supposed to explain how to install Sinatra in Bluehost.
You should follow these instructions. They almost result in a working
setup. The thing that doesn't work is the step 5. The code includes
this line in dispatch.fcgi:
This just doesn't work. I spent hours debugging and I'm pretty sure
that for some reason you cannot make gem system find the local gem
directory with this approach. I could verify that it's not about e.g.
file permissions. Instead you have to do:
ENV["GEM_HOME"] = "/homeX/YYYY/ruby/gems"
I put this after the first line in the script and before the like
Additionally, you need to install the fcgi gem, which at least I
didnt' have. Unfortunately "gem install fcgi" didn't work and I had to
resort article "Deploying rails app on BlueHost" in
http://penkin.co.uk/deploying-rails-app-on-bluehost/ for instruction
on how to install fcgi gem. I installed it like this:
tar -zxvf fcgi-2.2.2.tar.gz
make && make install
gem install fcgi -r -- --with-fcgi-include=$HOME/src/fcgi/include --
That's about it. The app should work now.
If you keep getting "Rails application failed to start properly" when
testing your app with your browser (the error message defined for HTTP
500 in .htaccess), a really valuable resource for debugging the root
cause of the error is the file /var/log/httpd/error_log. The problem
is that this file is shared by all users in the server and fills (in
my case) with crap all the time. This is not a problem, however. Just
do "less -n /var/log/httpd/error_log", hit F and do reload in your
browser and hit CTRL-C in the less command and you should see the real
error. Using this method I found e.g. that the fcgi gem was missing.
Also note that if you need to make any changes in the code
(dispatch.fcgi), you need to kill all your dispatch.fcgi processes
What a pain was it get running! But anyway, I finally got my app
hosted in the hosting provider I already had contracted.