Run eRuby on shared host

For small jobs like tiny webservices, I don’t want bother Ruby On Rails. Instead I used to pick php to build a quick restful web service. Actually we call also use ruby as a cgi platform to do the same job. as described in book.

One thing different for shared host user is, we can’t modify httpd file directly, instead, should use .htaccess as dreamhost wiki said.

Another problem is, how to set those environment variables, e.g. RUBYOPT, GEM_HOME, to load developer installed gem package?

Some google results said it’s impossible, at least if you try to set it code, and it only works for sub process, as mentioned in this one and this one.

Here is another post for how to achieve this by tweeting cgi, a bit of messy, but it works. Still don’t how to do it in cgi, (might need to change dispatch.cgi somewhere) but for eruby, create a shell wrapper for eruby.cgi to pre-set environment variables is quite easy.



Update: running into gem not load in eruby issue on a new VPS. couldn’t figure out why, just did a simple gem update. problem solved.

gem/rubygems version before update was 1.3.7

Maybe should also run a gem update –system in case.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s