Todays experiment: Ruby on Rails on a shared hosting webspace from 1and1

von

Before you spent too much time on this text: I have not managed to complete it. Maybe you have an idea, but I failed.

With GIT arriving, 1und1 (1and1) has decided to give SSH access to its users. They call it - surprise - GIT support. Of course it’s much more than that, for example you can compile code. I tried to get Ruby on Rails running, last night. I came pretty far, but finally failed with running Ruby on Rails through CGI. As I found out later, it seems CGI is not longer supported by Rails.

First, check your ruby version:

> ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux]

This is fine already. Then you need to do some tricks with gem. Gem is already preinstalled, but it would put your gem into a folder which is not writeable to you. Therefore you should create a .profile in your home directory. The content might look like:

export PREFIX=/kunden/homepages/19/YOUR_CUSTOMER_NUMBER/htdocs/path/to/libs
export GEM_HOME=$PREFIX/lib/ruby/gems/1.8
export RUBYLIB=$PREFIX/lib/ruby:$PREFIX/lib/site_ruby/1.8
export PATH=$PATH:$PREFIX/lib/ruby/gems/1.8/bin

While the first entries set your path to ruby and gem, the last one adds the new commands brought by gem to the path (such as rails). If you want to run Rails with SQlite, you need to install sqlite-ruby. But unfortunately sqlite is not available on the shell. Do it yourself:

>wget http://www.sqlite.org/sqlite-autoconf-3071300.tar.gz

Unzip the package to a location of your choice. Then do the usual:

./configure --prefix=/ABSOLUTE/PATH/TO/A/WRITEABLE/DIR
make PREFIX=/ABSOLUTE/PATH/TO/A/WRITEABLE/DIR
make install PREFIX=/ABSOLUTE/PATH/TO/A/WRITEABLE/DIR

As you have seen, I needed to prefix everything. Otherwise I am not able to perform the install task because of missing write permissions. After that you are able to install the sqlite3-ruby gem.

gem install sqlite3-ruby -- --with-sqlite3-dir=/ABSOLUTE/PATH/TO/A/WRITEABLE/DIR

Please mind the – which look like a typo. They are necessary to path the argument on to the underlying make (?) file.

Once done, we can create our application:

rails new myapp

But we are not finished yet. 1and1 has no JS engine available which is necessary to perform some cli stuff. We need to install therubyracer:

gem install therubyracer

And afterwards activate it in the Gemfile with uncommenting the following line:

gem 'therubyracer', :platforms => :ruby

Well ok, that’s it. In theory you should be able to point a domain to your public folder and see some cool Rails stuff after creating our first controller:

rails generate controller home index

Older versions should support CGI, but it seems this not working any longer. If there is a chance to bring this to fly without the Apache Passenger module, let me know.

Tags:

Newsletter

ABMELDEN