CSC/ECE 517 Fall 2013/ch1 1w28 nm: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(64 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Contents ==
This article explains the steps to install and configure Rails on Windows, Linux and Mac OSX. Since Linux and Mac OSX are UNIX based Operating Systems, their installation process is similar. In case of Windows, there are two methods to install ruby on rails i.e Using the command line or using the one-click installer. We have also included links to common problems faced during installation.
 
 
 
 
 
 
 
 
 
 
 


== '''Configuring rails environment for Linux and Mac OS X.''' ==
== '''Configuring rails environment for Linux and Mac OS X.''' ==
Line 17: Line 6:




Since both Mac OSX and Linux are UNIX based systems, the process of configuring rails in Linux and Mac OSX is very similar .
Since both Mac OSX<ref name='mac'>[http://stackoverflow.com/questions/6840719/installing-ruby-on-rails-mac-os-lion Mac Installation]</ref> and Linux<ref name='linux'>[http://en.wikibooks.org/wiki/Ruby_on_Rails/Getting_Started/Install_on_Linux Linux Installation]</ref> are UNIX based systems, the process of configuring rails in Linux and Mac OSX is very similar .




Line 23: Line 12:




===='''1. Install XCode or XCode command line tool.'''====
====''' Install XCode or XCode command line tool.'''====
For Mac OS X, the first thing we need to do is to install XCode which are the Apple Developer Tools.  
For Mac OS X, the first thing we need to do is to install XCode which are the Apple Developer Tools.  
XCode ships with Mac OS 10.6 i.e Snow Leopard.
XCode ships with Mac OS 10.6 i.e Snow Leopard.
XCode can be installed from the Mac OS X install DVD or can be downloaded from www.developer.apple.com/xcode.
XCode can be installed from the Mac OS X install DVD or can be downloaded from https://developer.apple.com/xcode/.<ref name='xcode'>[https://developer.apple.com/xcode/ Xcode]</ref>
You can verify if the XCode has been installed correctly by going to the terminal and running the following command:
You can verify if the XCode has been installed correctly by going to the terminal and running the following command:


gcc -v  
    gcc -v  


This command will check whether the required gcc compiler has been installed.  
This command will check whether the required gcc compiler has been installed.  
You can also install the XCode command line tool instead of the entire XCode developer tool.
You can also install the XCode command line tool<ref name='xcode tool'>[http://guide.macports.org/chunked/installing.xcode.html Xcode command line tools]</ref> instead of the entire XCode developer tool.


====''' Download git'''====


'''2. Download git-'''
Git is an open source distributed version control system designed to handle everything, from small to large projects with speed and efficiency.
Git allows you to have multiple branches that can be entirely independent of each other. The creation, merging and deletion of these development lines takes seconds.
It allows you to switch between these branches with ease.
If, at any time you feel that the branch is not required you can delete that branch and revert back to the previous branch.
You can download git-1.8.3.2(tar.gz file) from http://git-scm.com/  <ref name='git'>[http://git-scm.com/ Git]</ref> 
Then execute the following commands from the terminal:-


 Git is an open source distributed version control system designed to handle everything, from small to large projects with speed and efficiency.
    $ tar zxf git-1.8.3.2.tar.gz -- This command will extract the .tar file.
 Git allows you to have multiple branches that can be entirely independent of each other. The creation, merging and deletion of these development lines takes seconds.
 It allows you to switch between these branches with ease.
 If, at any time you feel that the branch is not required you can delete that branch and revert back to the previous branch.
 You can download git-1.8.3.2(tar.gz file) from www.git-scm.com 
 Then execute the following commands from the terminal:-


$ tar zxf git-1.8.3.2.tar.gz -- This command will extract the .tar file.
    $ cd git-1.8.3.2 -- This command will take the control into that directory.


$ cd git-1.8.3.2 -- This command will take the control into that directory.
    [cd git-1.8.3.2]$ make && sudo make install -- This command will compile and install git


[cd git-1.8.3.2]$ make && sudo make install -- This command will compile and install git
    [cd git-1.8.3.2]$ git --version --This command will return the current version of git installed on the machine.


[cd git-1.8.3.2]$ git --version --This command will return the current version of git installed on the machine.
====''' Ruby Version Manager'''====
   
The next step is to install Ruby Version Manager(RVM)<ref name='rvm'>[https://rvm.io/rvm/basics Ruby Version Manager]</ref>. This is an optional step.
All computers having Mac OS 10.6 and above have some version of ruby pre installed.
Therefore it is good practice to install RVM to manage different version of Ruby of the same machine.
This is particularly important if you want to run Rails3 and Rails2.3 on the same machine.
You can download RVM from www.rvm.io.
To install RVM, execute the following command in the terminal:-


    Install RVM with a Ruby: \curl -L https://get.rvm.io | bash -s stable
For all in one installation append --rails or --ruby or --ruby=1.9.3


====''' Install Ruby'''====


After installing RVM, you can install Ruby by using the following commands


    $ rvm update --head
    $ rvm reload
These commands will update and reload RVM as it is updated frequently.


'''3. Ruby Version Manager'''
    $ rvm install 1.8.7 --installs ruby 1.8.7
 The next step is to install Ruby Version Manager(RVM). This is an optional step.
 All computers having Mac OS 10.6 and above have some version of ruby pre installed.
 Therefore it is good practice to install RVM to manage different version of Ruby of the same machine.
 This is particularly important if you want to run Rails3 and Rails2.3 on the same machine.
 You can download RVM from www.rvm.io.
 To install RVM, execute the following command in the terminal:-


     Install RVM with a Ruby:
     $ rvm install 1.9.2 -- installs ruby 1.9.2
\curl -L https://get.rvm.io | bash -s stable
 For all in one installation append --rails or --ruby or --ruby=1.9.3


'''4. Install Ruby'''
====''' Install RubyGems'''====
If you want to use multiple versions of rails on the same machine,you need to create a separate gemset, which is a self contained bundles of gems, for each version.


 After installing RVM, you can install Ruby ny using the following commands
    $ rvm--create1.8.7-p174@rails2
    $ rvm--createuse1.9.2@rails3


$ rvm update --head
Here the first command creates the gemset rails2 associated with
$ rvm reload
Ruby1.8.7-p174, while the second command creates the gemset rails3 associated with Ruby1.9.2 and uses it at the same time.
These commands will update and reload RVM asit is updated frequently.  


$ rvm install 1.8.7 --installs ruby 1.8.7
You can download RubyGems<ref name='rubygems'>[http://rubygems.org/pages/download RubyGems]</ref> and install them using them using the following command:
    $ sudo ruby setup.rb


$ rvm install 1.9.2 -- installs ruby 1.9.2
If you already have RubyGems installed on your machine you can update it using the following command:-


'''5. Install RubyGems'''
 If you want to use multiple versions of rails on the same machine,you need to create a separate gemset, which is a self contained bundles of gems, for each version.


$ rvm--create1.8.7-p174@rails2
    $ sudo gem update --system
$ rvm--createuse1.9.2@rails3


 Here the first command creates the gemset rails2 associated with
==== '''Install Rails'''====
Ruby1.8.7-p174, while the second command creates the gemset rails3 associated with Ruby1.9.2 and uses it at the same time.


 You can download RubyGems and install them using them using the following command:
The last step is to install rails. This can be done as follows:-
[RubyGems]$ sudo ruby setup.rb


 If you already have RubyGems installed on your machine you cane update it using the following command:-
    $ gem install rails --version 3.2.13


It is possible to check whether rails is installed correctly or not using


$ sudo gem update --system
    $ rails -v


This command should return the installed version of rails and will return an error if rails has not been installed correctly.


----


== '''Configuring rails environment for Windows''' ==


6. '''Install Rails'''
----


 The last step is to install rails. This can be done as follows:-


$ gem install rails --version 3.2.13


 It is possible to check whether rails is installed correctly or not using
There are many ways in which one might want to set up a complete development environment for Ruby on Rails on a Windows machine. There are primarily two types of installations
===''' Using Command Line Instructions'''===
Here we are going to cover how to setup Rails on a Windows machine using Ruby, Ruby Gems and Rails.


$ rails -v
====''' Installing GIT'''====
Installing Git on Windows is very simple. Simply download the installer (.exe) file from the GitHub<ref name='git'>[http://git-scm.com/downloads Git Download]</ref> page, and run it.


This command should return the installed version of rails and will return an error if rails has not been installed correctly.


----
[[Image:git.png|frame|center|Git Install]]




== '''Configuring rails environment for Windows''' ==
----


[[Image:git1.png|frame|center|Git Option Selection]]




There are many ways in which one might want to set up a complete development environment for Ruby on Rails on a Windows machine. There are primarily two types of installations
'''I. Using Command Line Instructions'''
Here we are going to cover how to setup Rails on a Windows machine using Ruby, Ruby Gems and Rails.
'''1. Installing GIT'''
Installing Git on Windows is very simple. Simply download the installer exe file from the GitHub page, and run it:
http://msysgit.github.com/
After it’s installed, you have both a command-line version (including an SSH client) and the standard GUI.
After it’s installed, you have both a command-line version (including an SSH client) and the standard GUI.


'''2. Ruby Installation:'''
====''' Ruby Installation:'''====
Download and install the latest final version of the Ruby installer (currently 1.8.6) from the www.rubyforge.org website.  
Download and install the latest final version of the Ruby installer (currently 1.8.6) from http://rubyforge.org/ .  
Ruby Installer for windows
 
Continue with the installations with all the default settings. Make sure that Ruby is installed in a path which doesn’t contain any spaces. The default path selected by the installation wizard is c: //Ruby
Continue with the installations with all the default settings. Make sure that Ruby is installed in a path which doesn’t contain any spaces. The default path selected by the installation wizard is c: //Ruby


'''3.''' '''Check Installation'''
====''''' Check Installation'''====
Once the installation is complete check that all the ruby commands are added to the file path. Open the command prompt and type
Once the installation is complete check that all the ruby commands are added to the file path. Open the command prompt and type


C:/> ruby –v
    C:/> ruby –v
The above instruction will display the version of ruby installed.
The above instruction will display the version of ruby installed.
C:/> gem –v
[[Image:ruby.png|frame|center|Ruby]]
    C:/> gem –v
[[Image:gem.png|frame|center|Version of installed Gem]]
The above instruction will display the version of gem installed.
The above instruction will display the version of gem installed.


If you get the “not recognized as an internal or external command” error, then set the path to the ruby bin directory (e.g. c:\ruby\bin) and try again.
If you get the “not recognized as an internal or external command” error, then set the path to the ruby bin directory (e.g. c:\ruby\bin) and try again.


'''4. Update RubyGems'''
====''' Update RubyGems'''====
The above installer also installs RubyGems package and SciTE editor as part of the installation process. But, the installed version of RubyGems may be a bit old(~0.9.4), so we need to update it to the latest available version.
The above installer also installs RubyGems package and SciTE editor as part of the installation process. But, the installed version of RubyGems may be a bit old(~0.9.4), so we need to update it to the latest available version.
C:\> gem update ––system
    C:\> gem update ––system
C:\> gem –v
The lasts updated version will be displayed.


'''5. Installing Rails'''
[[Image:update.png|frame|center|Update Gems]]
    C:\> gem –v  The lasts updated version will be displayed.
 
====''' Installing Rails'''====
Once Ruby and RubyGems have been installed run the following command on the command prompt to install Ruby on Rails and all its dependencies.  
Once Ruby and RubyGems have been installed run the following command on the command prompt to install Ruby on Rails and all its dependencies.  


C:\> gem install rails - -include-dependencies
    C:\> gem install rails - -include-dependencies
C:\> rails -v
[[Image:rails.png|frame|center|Installing Rails]]
 
    C:\> rails -v
 
[[Image:railsversion.png|frame|center|Installed version of rails]]


      If you want to update the version of Rails, just run the following commands
If you want to update the version of Rails, just run the following commands


  C:\> gem update rails
  C:\> gem update rails
Line 163: Line 157:
The simple Rails development environment is now installed on the System with WEBrick as the web server, SQLite as the database server.
The simple Rails development environment is now installed on the System with WEBrick as the web server, SQLite as the database server.


 
===''' Using Windows Rails Installer'''===
'''II. Using Windows Rails Installer'''


1. Go to Rails Installer and download the Rails Installer executable.  
1. Go to Rails Installer and download the Rails Installer executable.  
  http://railsinstaller.org/en
  http://railsinstaller.org/en
[[Image:windows.png|frame|center|Rails Installer]]


2. Double-click the executable and follow the instructions to install Git, Ruby, RubyGems, and Rails itself.
2. Double-click the executable and follow the instructions to install Git, Ruby, RubyGems, and Rails itself.
[[Image:setup.png|frame|center|Setup Wizard]]
[[Image:agreement.png|frame|center|Agreement]]
[[Image:final.png|frame|center|Install]]


3. Once the installation is done, the environment is set up and ready for the first application.
3. Once the installation is done, the environment is set up and ready for the first application.




[[Image:installed.png|frame|center|Installation Complete]]




'''References:'''
=='''See Also'''==
[http://joehacker72.wordpress.com/category/ruby-on-rails/ Rails installation problem on Linux]


1.http://joehacker72.wordpress.com/category/ruby-on-rails/
[http://stackoverflow.com/questions/12746060/how-to-install-rails-mac-osx-mountain-lion Rails installation problem on Mac OSX]


2.http://ruby.railstutorial.org/
[http://stackoverflow.com/questions/12256616/os-x-mountain-lion-gcc-4-2-no-such-file-or-directory gcc problem in mac]


3.Ruby on Rails Tutorial-Learn Rails by Example by  
[http://ruby.railstutorial.org/book/ruby-on-rails-tutorial#sec-rubygems Ruby on Rails Tutorial-Learn Rails by Example by Michael Hartl]


4.Pro Git by Scott Chacon
=='''References:'''==
<references/>

Latest revision as of 20:20, 24 September 2013

This article explains the steps to install and configure Rails on Windows, Linux and Mac OSX. Since Linux and Mac OSX are UNIX based Operating Systems, their installation process is similar. In case of Windows, there are two methods to install ruby on rails i.e Using the command line or using the one-click installer. We have also included links to common problems faced during installation.

Configuring rails environment for Linux and Mac OS X.



Since both Mac OSX<ref name='mac'>Mac Installation</ref> and Linux<ref name='linux'>Linux Installation</ref> are UNIX based systems, the process of configuring rails in Linux and Mac OSX is very similar .


Steps for configuring Rails:

Install XCode or XCode command line tool.

For Mac OS X, the first thing we need to do is to install XCode which are the Apple Developer Tools. XCode ships with Mac OS 10.6 i.e Snow Leopard. XCode can be installed from the Mac OS X install DVD or can be downloaded from https://developer.apple.com/xcode/.<ref name='xcode'>Xcode</ref> You can verify if the XCode has been installed correctly by going to the terminal and running the following command:

   gcc -v 

This command will check whether the required gcc compiler has been installed. You can also install the XCode command line tool<ref name='xcode tool'>Xcode command line tools</ref> instead of the entire XCode developer tool.

Download git

Git is an open source distributed version control system designed to handle everything, from small to large projects with speed and efficiency. Git allows you to have multiple branches that can be entirely independent of each other. The creation, merging and deletion of these development lines takes seconds. It allows you to switch between these branches with ease. If, at any time you feel that the branch is not required you can delete that branch and revert back to the previous branch. You can download git-1.8.3.2(tar.gz file) from http://git-scm.com/ <ref name='git'>Git</ref> Then execute the following commands from the terminal:-

   $ tar zxf git-1.8.3.2.tar.gz -- This command will extract the .tar file.
   $ cd git-1.8.3.2 -- This command will take the control into that directory.
   [cd git-1.8.3.2]$ make && sudo make install -- This command will compile and install git
   [cd git-1.8.3.2]$ git --version --This command will return the current version of git installed on the machine.

Ruby Version Manager

The next step is to install Ruby Version Manager(RVM)<ref name='rvm'>Ruby Version Manager</ref>. This is an optional step. All computers having Mac OS 10.6 and above have some version of ruby pre installed. Therefore it is good practice to install RVM to manage different version of Ruby of the same machine. This is particularly important if you want to run Rails3 and Rails2.3 on the same machine. You can download RVM from www.rvm.io. To install RVM, execute the following command in the terminal:-

   Install RVM with a Ruby: \curl -L https://get.rvm.io | bash -s stable

For all in one installation append --rails or --ruby or --ruby=1.9.3

Install Ruby

After installing RVM, you can install Ruby by using the following commands

   $ rvm update --head
   $ rvm reload

These commands will update and reload RVM as it is updated frequently.

   $ rvm install 1.8.7 --installs ruby 1.8.7
   $ rvm install 1.9.2 -- installs ruby 1.9.2

Install RubyGems

If you want to use multiple versions of rails on the same machine,you need to create a separate gemset, which is a self contained bundles of gems, for each version.

   $ rvm--create1.8.7-p174@rails2
   $ rvm--createuse1.9.2@rails3

Here the first command creates the gemset rails2 associated with Ruby1.8.7-p174, while the second command creates the gemset rails3 associated with Ruby1.9.2 and uses it at the same time.

You can download RubyGems<ref name='rubygems'>RubyGems</ref> and install them using them using the following command:

   $ sudo ruby setup.rb

If you already have RubyGems installed on your machine you can update it using the following command:-


   $ sudo gem update --system

Install Rails

The last step is to install rails. This can be done as follows:-

   $ gem install rails --version 3.2.13

It is possible to check whether rails is installed correctly or not using

   $ rails -v

This command should return the installed version of rails and will return an error if rails has not been installed correctly.


Configuring rails environment for Windows



There are many ways in which one might want to set up a complete development environment for Ruby on Rails on a Windows machine. There are primarily two types of installations

Using Command Line Instructions

Here we are going to cover how to setup Rails on a Windows machine using Ruby, Ruby Gems and Rails.

Installing GIT

Installing Git on Windows is very simple. Simply download the installer (.exe) file from the GitHub<ref name='git'>Git Download</ref> page, and run it.


Git Install


Git Option Selection


After it’s installed, you have both a command-line version (including an SSH client) and the standard GUI.

Ruby Installation:

Download and install the latest final version of the Ruby installer (currently 1.8.6) from http://rubyforge.org/ .

Continue with the installations with all the default settings. Make sure that Ruby is installed in a path which doesn’t contain any spaces. The default path selected by the installation wizard is c: //Ruby

Check Installation

Once the installation is complete check that all the ruby commands are added to the file path. Open the command prompt and type

   C:/> ruby –v

The above instruction will display the version of ruby installed.

Ruby
   C:/> gem –v
Version of installed Gem

The above instruction will display the version of gem installed.

If you get the “not recognized as an internal or external command” error, then set the path to the ruby bin directory (e.g. c:\ruby\bin) and try again.

Update RubyGems

The above installer also installs RubyGems package and SciTE editor as part of the installation process. But, the installed version of RubyGems may be a bit old(~0.9.4), so we need to update it to the latest available version.

   C:\> gem update ––system
Update Gems
   C:\> gem –v  The lasts updated version will be displayed.

Installing Rails

Once Ruby and RubyGems have been installed run the following command on the command prompt to install Ruby on Rails and all its dependencies.

   C:\> gem install rails - -include-dependencies
Installing Rails
   C:\> rails -v
Installed version of rails

If you want to update the version of Rails, just run the following commands

	C:\> gem update rails

The simple Rails development environment is now installed on the System with WEBrick as the web server, SQLite as the database server.

Using Windows Rails Installer

1. Go to Rails Installer and download the Rails Installer executable.

http://railsinstaller.org/en
Rails Installer


2. Double-click the executable and follow the instructions to install Git, Ruby, RubyGems, and Rails itself.


Setup Wizard


Agreement


Install


3. Once the installation is done, the environment is set up and ready for the first application.


Installation Complete


See Also

Rails installation problem on Linux

Rails installation problem on Mac OSX

gcc problem in mac

Ruby on Rails Tutorial-Learn Rails by Example by Michael Hartl

References:

<references/>