Wednesday, July 15, 2009

Installing Ruby on Rails, Apache2 And Passenger in Linux

1. Installing Ruby on Rails:

i. Download the latest ruby source and rubygems source to /usr/local/src/ and

extract them. At the time of this writing, those commands were:

ii. cd /usr/local/src

iii. wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz (wget is the

cmd which downloads the tar.gz file)

iv. tar xzf ruby-1.8.7-p72.tar.gz

v. wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz

vi. tar xzf rubygems-1.3.1.tgz

2. Go into the Ruby directory and compile it, like so:

cd ruby-1.8.7-p72

./configure

make

NOTE: This was the key part to watch. This time around, you should see

compile messages stating that zlib was compiled successfully at the end of the

log on your screen.

3. Now install Ruby, if all went well:

make install

4. Now go setup RubyGems, like so:

cd ../rubygems-1.3.1

ruby setup.rb

5. Update the gem system for good measure

gem update --system

6. Install Rails

gem install rails

How to Install the Apache Web Server?

Apache is one of the most popular Web servers on the Web right now, and

part of its charm is that it's free. It also has a lot of features that make it very

extensible and useful for many different types of Web sites. It is a server that

is used for personal Web pages up to enterprise level sites.

This article will discuss how to install Apache on a Linux system. Before we

start you should be at least comfortable working in Linux - changing

directories, using tar and gunzip, and compiling with make (I'll discuss where

to get binaries if you don't want to mess with compiling your own). You should

also have access to the root account on the server machine.

Download Apache:

I recommend downloading the latest stable release. At the time of this

writing, that was Apache 2.0. The best place to get Apache is from the

Apache HTTP Server download site. Download the sources appropriate to

your system. Binary releases are available as well.

Extract the Files:

Once you've downloaded the files you need to uncompress them and

untarring:

i. gunzip -d httpd-2_0_NN.tar.gz

ii. tar xvf httpd-2_0_NN.tar

This creates a new directory under the current directory with the source

files.

Configuring:

Once you've got the files, you need to tell your machine where to find

everything by configuring the source files. The easiest way is to accept all

the defaults and just type:

./configure

Of course, most people don't want to accept just the default choices. The most

important option is the prefix= option. This specifies the directory where the

Apache files will be installed. You can also set specific environment variables

and modules. Some of the modules I like to have installed are:

* mod_alias - to map different parts of the URL tree

* mod_include - to parse Server Side Includes

* mod_mime - to associate file extensions with its MIME-type

* mod_rewrite - to rewrite URLs on the fly

* mod_speling (sic) - to help your readers who might misspell URLs

* mod_ssl - to allow for strong cryptography using SSL

* mod_userdir - to allow system users to have their own Web page directories

Please keep in mind that these aren't all the modules I might install on a given

system. Read the details about the modules to determine which ones you

need.

Build:

As with any source installation, you'll then need to build the installation:

make

make install

Customize:

Assuming that there were no problems, you are ready to customize your

Apache configuration. This really just amounts to editing the httpd.conf file.

This file is located in the PREFIX/conf directory. I generally edit it with vi:

vi PREFIX/conf/httpd.conf

Note: you'll need to be root to edit this file.

Follow the instructions in this file to edit your configuration the way you want

it. More help is available on the Apache Web site.

Test Your Server:

Open a Web browser on the same machine and type http://localhost/ in the

address box. You should see a page similar to the one in the partial screen

shot above. Specifically, it will say in big letters "Seeing this instead of the

website you expected?" This is good news, as it means your server installed

correctly.

Start Editing/Uploading Pages

Once your server is up and running you can start posting pages. Have fun

building your Web site.


Easiest way to install Passenger:

# Open a terminal, and type:

gem install passenger

# Type:

passenger-install-apache2-module

Or, if you want to install the Nginx version instead:

passenger-install-nginx-module

2 comments:

  1. Easy to set up web alternatives using
    Ruby on Rails as it works well with broad range of web servers and directories that apply CGI or Fast SGI.

    ReplyDelete
  2. Your blog post is amazing and full of knowledge, thanks for publishing your post. I want to tell you everyone that I also provide a Customize Ruby On Rails Services at a very prominent price.

    ReplyDelete