How to install Ruby on Rails in Ubuntu 11.10

step 1. Install dependencies

 

Install git : Git is the most popular (aswell as fast and efficient; Linux kernel uses it; developed by Linux Torwalds,the same guy who developed Linux kernel) open source version control system.You can install it in one simple command to install it from the officialpackage repository -

 

sudo apt-get install git

[You could also install git from the source(Download the source code, extract it and execute make && sudo makeinstall) ]

Install Curl : Curl is a command line toolto get a file from FTP/HTTP/HTTPS server. To install, open terminal and executethe command -

 

sudo apt-get install curl

step 2. Install RVM (Ruby Version Manager)

 

Open terminal and execute the command (Iassume you’ve already completed the step 1, otherwise first do that) -

 

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

Now, you might have to edit the bashrc fileto load RVM in shell session. To do that type -

 

gedit ~/.bashrc

and add the following line to the end (andsave the file)

[[ -s "$HOME/.rvm/scripts/rvm" ]]&& source "$HOME/.rvm/scripts/rvm" # Load RVM into a shellsession *as a function*

 Thenreload the shell session using the command -

 

gedit ~/.bashrc

Now you can test whether the RVM has beeninstalled successfully or not. Open terminal and execute the command -

type rvm | head -1

After executing above command you should begetting this output -

rvm is a function

 That’s All.. You’ve successfully installed theRVM. Next, you are supposed to install few additional dependencies. To find outthose programs type -

 

rvm requirements

 

After executing the above command, installthe additional packages recommended by RVM -

 

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

step 3. Install Ruby

 

Now, it’s time to install the ruby versionyou want (you’re recommended to use either 1.8.7 or1.9.2). The generic syntax is rvm use version_name. It will also install theassociated packages such as RubyGems and Bundler.

 

rvm install 1.9.2

Then select the version, you want to use -

rvm use 1.9.2

If you aren’t sure about the ruby versioncurrently being used, then type -

ruby -v

step 4. install Rails

 

Finally, you can install the rails gemusing a simple command -

 

gem install rails

That’s All.

Now,create a sample application (just for testing) using Ruby on Rails.

 

rails new my_app 

bundleinstall

cdmy_app

rails server

Then open your browser and type thefollowing address (to see the application running) -

http://localhost:3000

转自:http://blog.sudobits.com/2011/10/27/how-to-install-ruby-on-rails-in-ubuntu-11-10/ 

相关推荐