rog
06-19-2005, 06:15 PM
This is a small howto guide that will help you get Ruby on Rails installed here at Hard Hat Hosting. Once you get Ruby on Rails (http://www.rubyonrails.org/) installed, it's quite simple to use the Ajax on Rails (http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html?page=1) technique as well.
At the end of the howto I'll address FastCGI support for Apache as well.
This assumes you are comfortable working on your host's shell through ssh. Some familiarity with compiling and installing software on Linux is assumed also.
Installing Ruby
I'd suggest creating a directory for all of the software you're going to be downloading and installing. I created a directory named "temp" at the root of my filesystem, but you can use whatever name and location you wish.
cd /
mkdir temp
chmod 775 temp
Now let's download, configure and install Ruby. You should download the latest stable source tarball for Ruby from here (http://www.ruby-lang.org/en/20020102.html).
I use wget to download files straight to the shell -- you can use another method if you wish but I'll use wget for this howto since it is very straightforward:
cd temp
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.2.tar.gz
tar -zxvf ruby-1.8.2.tar.gz
cd ruby-1.8.2
One of the "tricks" needed for installation on a shared host like Hard Hat is that you often need to specify an install directory, because sometimes you don't have permissions to install things in their normal directories. You'll notice this throughout the howto.
So let's run through the "configure" script for Ruby, specifying a directory inside "/usr/local" for installation:
./configure --prefix=/usr/local/ruby --exec-prefix=/usr/local/ruby
That should run successfully, leaving you with a Makefile that's ready to compile:
make
make install
Ruby is now installed! Before we continue, you'll want to make a symbolic link to Ruby somewhere in your local path:
ln -s /usr/local/ruby/bin/ruby /usr/local/bin/ruby
We'll need some other sym links later, but this should get us started.
Installing RubyGems
RubyGems (http://docs.rubygems.org/) (also called "Gem") is a package management tool that lets you easily install extra packages and libraries for Ruby. We'll need Gem to install the Rails package.
You can download the latest version of RubyGems here (http://rubyforge.org/frs/?group_id=126).
cd /junk
wget http://rubyforge.org/frs/download.php/3700/rubygems-0.8.10.tgz
tar -zxvf rubygems-0.8.10.tgz
cd rubygems-0.8.10
Now let's install RubyGems. You'll use Ruby to call the setup script:
ruby setup.rb
You should see "Successfully built RubyGem" after that finishes. We'll need to make one edit so that Gem knows where to find our custom Ruby installation. Open the file "/usr/local/ruby/bin/gem" in your favorite text editor (such as vi) and edit the first line so that it looks like this:
#!/usr/local/bin/ruby
Also, let's add a few more symlinks:
cd /usr/local/bin
ln -s /usr/local/ruby/bin/erb erb
ln -s /usr/local/ruby/bin/eruby eruby
ln -s /usr/local/ruby/bin/gem gem
ln -s /usr/local/ruby/bin/gem_server gem_server
ln -s /usr/local/ruby/bin/testrb testrb
ln -s /usr/local/ruby/bin/update_rubygems update_rubygems
That's it for RubyGems!
Installing Rails
Now that we have Gem installed, getting Rails up is super easy. Here's the skinny:
gem install rails --remote
Holy cow that was easy!
Now that you have Ruby and Rails up and running, you'll want to test it out, probably with a MySQL database. Since you came here for Ruby on Rails installation instructions, presumably you already have a database project in mind. If not, I'd highly suggest this Rolling with Ruby on Rails (http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=1) article which creates a sample cookbook application. Since we've already installed Ruby, Rails, and MySQL (MySQL is installed through your Hard Hat control panel if you haven't already installed it), you can start on page 2 (http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=2) of the article.
You can see my own demo of this cookbook application on Rails here (http://xmlareas.com/rails/recipe/list).
Using AJAX and FastCGI
coming soon...
At the end of the howto I'll address FastCGI support for Apache as well.
This assumes you are comfortable working on your host's shell through ssh. Some familiarity with compiling and installing software on Linux is assumed also.
Installing Ruby
I'd suggest creating a directory for all of the software you're going to be downloading and installing. I created a directory named "temp" at the root of my filesystem, but you can use whatever name and location you wish.
cd /
mkdir temp
chmod 775 temp
Now let's download, configure and install Ruby. You should download the latest stable source tarball for Ruby from here (http://www.ruby-lang.org/en/20020102.html).
I use wget to download files straight to the shell -- you can use another method if you wish but I'll use wget for this howto since it is very straightforward:
cd temp
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.2.tar.gz
tar -zxvf ruby-1.8.2.tar.gz
cd ruby-1.8.2
One of the "tricks" needed for installation on a shared host like Hard Hat is that you often need to specify an install directory, because sometimes you don't have permissions to install things in their normal directories. You'll notice this throughout the howto.
So let's run through the "configure" script for Ruby, specifying a directory inside "/usr/local" for installation:
./configure --prefix=/usr/local/ruby --exec-prefix=/usr/local/ruby
That should run successfully, leaving you with a Makefile that's ready to compile:
make
make install
Ruby is now installed! Before we continue, you'll want to make a symbolic link to Ruby somewhere in your local path:
ln -s /usr/local/ruby/bin/ruby /usr/local/bin/ruby
We'll need some other sym links later, but this should get us started.
Installing RubyGems
RubyGems (http://docs.rubygems.org/) (also called "Gem") is a package management tool that lets you easily install extra packages and libraries for Ruby. We'll need Gem to install the Rails package.
You can download the latest version of RubyGems here (http://rubyforge.org/frs/?group_id=126).
cd /junk
wget http://rubyforge.org/frs/download.php/3700/rubygems-0.8.10.tgz
tar -zxvf rubygems-0.8.10.tgz
cd rubygems-0.8.10
Now let's install RubyGems. You'll use Ruby to call the setup script:
ruby setup.rb
You should see "Successfully built RubyGem" after that finishes. We'll need to make one edit so that Gem knows where to find our custom Ruby installation. Open the file "/usr/local/ruby/bin/gem" in your favorite text editor (such as vi) and edit the first line so that it looks like this:
#!/usr/local/bin/ruby
Also, let's add a few more symlinks:
cd /usr/local/bin
ln -s /usr/local/ruby/bin/erb erb
ln -s /usr/local/ruby/bin/eruby eruby
ln -s /usr/local/ruby/bin/gem gem
ln -s /usr/local/ruby/bin/gem_server gem_server
ln -s /usr/local/ruby/bin/testrb testrb
ln -s /usr/local/ruby/bin/update_rubygems update_rubygems
That's it for RubyGems!
Installing Rails
Now that we have Gem installed, getting Rails up is super easy. Here's the skinny:
gem install rails --remote
Holy cow that was easy!
Now that you have Ruby and Rails up and running, you'll want to test it out, probably with a MySQL database. Since you came here for Ruby on Rails installation instructions, presumably you already have a database project in mind. If not, I'd highly suggest this Rolling with Ruby on Rails (http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=1) article which creates a sample cookbook application. Since we've already installed Ruby, Rails, and MySQL (MySQL is installed through your Hard Hat control panel if you haven't already installed it), you can start on page 2 (http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=2) of the article.
You can see my own demo of this cookbook application on Rails here (http://xmlareas.com/rails/recipe/list).
Using AJAX and FastCGI
coming soon...