A collection of computer systems and programming tips that you may find useful.
 
Brought to you by Craic Computing LLC, a bioinformatics consulting company.

Monday, January 22, 2007

Installing Rails 1.2.1 on Fedora Linux Core 5

There is a proliferation of installation guides at rubyonrails.org and elsewhere. Unfortunately some of these add more confusion than clarity, particularly if the author had to use some funky hack to get things working.

Here are the steps I've taken to install Rails on Fedora Core 5. The Fedora installation included Mysql and its development tools, as well as an installation of Ruby.

You should be root when you install the software. The following steps will install into /usr/bin. Installing into /usr/local/bin protects you from future linux upgrades, but involves additional steps.

1. Update all the basic Ruby packages
# yum update ruby ruby-libs ruby-mode ruby-devel ruby-rdoc ruby-irb ruby-ri ruby-docs

2. Install rubygems
- Get the tar file from http://rubyforge.org/projects/rubygems
- Pick up the latest (at least Rel_0_9_1)
- Download the file (e.g. rubygems_0.9.1.tgz) into a temporary directory
- Extract the file (tar xzvf rubygems_0.9.1.tgz) and cd into that directory
- Run the setup script
# ruby setup.rb

3. Use the gem package manager to install Rails
# gem install rails --include-dependencies

4. At this point you can test out the Rails installation
- cd to a scratch directory and run
# rails myapp

- This will create a directory tree with myapp as its root
# cd myapp
# script/server

- That starts the built-in web server. Point your browser to http://localhost:3000 and you should see the 'Welcome Aboard' home page for the project. If so then your basic installation is good - but you can't actually do anything with it yet.

5. Install Mysql if you don't already have it
# yum install mysql mysql-devel mysql-server

6. Start the mysqld and give the root account a password
# /sbin/service mysqld start
# mysqladmin -u root password <your_password>

7. Install the Ruby / MySQL Bindings
- This has caused confusion in some of the install guides - this works for me.
- Be very careful not to mix up your hyphens and underscores!
- This command does have two hyphens by themselves after the mysql
# gem install mysql -- --with-mysql-config=/usr/bin/mysql_config

You will be prompted for the version of the gem to install. Pick the latest MySQL version for Ruby (e.g. mysql 2.7 (ruby))

At this point you can create a basic Rails application with associated databases and access it from your browser via the built in Webrick server.

The installation is complete with the exception of linking Rails to a production web server like Apache. That can be its own can of worms and so that will be covered in its own posting on this site.

1 comment:

Blogger said...

If you need your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (even if they're dating somebody else now) you need to watch this video
right away...

(VIDEO) Text Your Ex Back?

Archive of Tips