Hulihan Applications
about projects services contact_us
We're a Web Development & Graphic Design Company. We make logos, websites, software, 3D graphics, and more!

We also make free, open source, software. Take a look and try them out. If you like them, let us know what you think.

Installing Custom Gems on a Shared Host

Have you ever wanted to install any gem you want on your account with a shared hosting company, like hostmonster, bluehost, dreamhost, railsplayground, etc? Here's how you can do it!

 

Before we begin, you'll need ssh access to your account. Log into to your ssh now!

 

First, we must create a directory you can install local gems to

cd ~
mkdir .gem bin lib src

Next, install your own local executable of rubygems. This step is optional, but I like to have the latest version of gem on my account, so I can update it as needed. At the time of this post, the latest version of rubygems is 1.3.7.

cd ~/src
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
tar xzvf rubygems-1.3.*
d rubygems-1.3.*
ruby setup.rb --prefix=$HOME
cd ~/bin
ln -s gem1.8 gem
cd ~

Next, add this  to the your user's .bash_profile file(~/.bash_profile), so the gem command knows where to install new gems:

export PATH="$HOME/bin:$HOME/.gem/bin:$PATH"
export RUBYLIB="$HOME/lib:$RUBYLIB"
export GEM_HOME="$HOME/.gem"
export GEM_PATH="/usr/lib/ruby/gem/1.8:$GEM_HOME"
alias gem="nice -n19 ~/bin/gem"

After this step is completely, re-login to your account to apply these changes.

Next, verify that the gem command you're using is in the right place:

which gem   # should return /home/USERNAME/bin/gem
gem -v      # should return 1.3.7

 

That's pretty much it! You can now install gems locally to your account using the command gem install [gemname].

Now, if your application needs access to a gem that's installed locally to your account, add this to your application's config/environment.rb or config.ru(if you're using a rackup config file).

That's it!

Special Thanks goes to Katz for her guide on installing gems on dreamhost.

 




Hulihan Applications © 2007-2010
No portion of this site may be copied, altered, duplicated or otherwise used without the express written approval of Hulihan Applications.