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

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
 
(36 intermediate revisions by the same user not shown)
Line 1: Line 1:
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 4: 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 10: 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 https://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:


Line 19: Line 21:


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.


===='''2. Download git'''====
====''' 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 is an open source distributed version control system designed to handle everything, from small to large projects with speed and efficiency.  
Line 27: Line 29:
It allows you to switch between these branches with ease.  
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.
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/   
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:-  
Then execute the following commands from the terminal:-  


Line 38: Line 40:
     [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.


===='''3. Ruby Version Manager'''====
====''' Ruby Version Manager'''====
The next step is to install Ruby Version Manager(RVM). This is an optional step.
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.  
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.
Therefore it is good practice to install RVM to manage different version of Ruby of the same machine.
Line 49: Line 51:
For all in one installation append --rails or --ruby or --ruby=1.9.3
For all in one installation append --rails or --ruby or --ruby=1.9.3


===='''4. Install Ruby'''====
====''' Install Ruby'''====


After installing RVM, you can install Ruby by using the following commands
After installing RVM, you can install Ruby by using the following commands
Line 61: Line 63:
     $ rvm install 1.9.2 -- installs ruby 1.9.2
     $ rvm install 1.9.2 -- installs ruby 1.9.2


===='''5. Install RubyGems'''====
====''' 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.
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.


Line 70: Line 72:
Ruby1.8.7-p174, while the second command creates the gemset rails3 associated with Ruby1.9.2 and uses it at the same time.
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:
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
     $ sudo ruby setup.rb


Line 78: Line 80:
     $ sudo gem update --system
     $ sudo gem update --system


====6. '''Install Rails'''====
==== '''Install Rails'''====


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


----
----


== '''Configuring rails environment for Windows''' ==
== '''Configuring rails environment for Windows''' ==
Line 100: Line 101:


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  
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  
==='''1. Using Command Line Instructions'''===
===''' Using Command Line Instructions'''===
Here we are going to cover how to setup Rails on a Windows machine using Ruby, Ruby Gems and Rails.  
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'''====
Installing Git on Windows is very simple. Simply download the installer exe file from the GitHub page, and run it:
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.
http://msysgit.github.com/
 
 
[[Image:git.png|frame|center|Git Install]]
 
 
 
[[Image:git1.png|frame|center|Git Option Selection]]
 
 
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 http://rubyforge.org/ .  
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
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


Line 125: Line 134:
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
Line 132: Line 141:
     C:\> gem –v  The lasts updated version will be displayed.
     C:\> gem –v  The lasts updated version will be displayed.


===='''5. Installing Rails'''====
====''' 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.  


Line 148: 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.


==='''2. Using Windows Rails Installer'''===
===''' 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.


3. Once the installation is done, the environment is set up and ready for the first application.
 
 
[[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.


=='''References:'''==


1.http://rubyforge.org/


2.http://ruby.railstutorial.org/
[[Image:installed.png|frame|center|Installation Complete]]


3.http://railsinstaller.org/en


4.Pro Git by Scott Chacon
=='''See Also'''==
[http://joehacker72.wordpress.com/category/ruby-on-rails/ Rails installation problem on Linux]


5.Ruby on Rails Tutorial-Learn Rails by Example by Michael Hartl
[http://stackoverflow.com/questions/12746060/how-to-install-rails-mac-osx-mountain-lion Rails installation problem on Mac OSX]


6.http://joehacker72.wordpress.com/category/ruby-on-rails/
[http://stackoverflow.com/questions/12256616/os-x-mountain-lion-gcc-4-2-no-such-file-or-directory gcc problem in mac]


7.http://en.wikibooks.org/wiki/Ruby_on_Rails/Getting_Started/Install_on_Linux
[http://ruby.railstutorial.org/book/ruby-on-rails-tutorial#sec-rubygems Ruby on Rails Tutorial-Learn Rails by Example by Michael Hartl]


8.http://camtyler.com/development/ruby/install-rails-on-linux-mint-14
=='''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/>