For beginners, how to install Ruby, Ruby gems, and rails execution environments may be a problem. This section describes how to install the ruby development environment quickly with a reliable path.
The same installation method applies to the product environment!
System Requirements
First, determine the operating system environment. It is not recommended to do this on windows, so you need to use:
- Mac OS X
- Free Linux release version (Ubuntu, centos, RedHat, archlinux ...)
It is strongly recommended that new users use Ubuntu to save unnecessary trouble!
In the following code area, the $ header must be run (excluding the $ symbol) below the console (terminal)
Step 0-install the required package
# For Mac
# First install [Xcode] (http://developer.apple.com/xcode/) development tools, it will help you install the development packages required by the Unix environment
# Then install [Homebrew] (http://brew.sh)
ruby -e "$ (curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
Step 1-install rvm
Here we will not explain what rvm is doing, but you will make it clearer later.
$ curl -L https://get.rvm.io | bash -s stable
During this period, you may be asked about the sudo administrator password and manually passhomebrewInstall the dependency package. After a while, you can install rvm successfully.
Then, load the rvm environment (the new termal does not need to be done, and will automatically load it again)
$ source ~/.rvm/scripts/rvm
Check whether the installation is correct
$ rvm -vrvm 1.22.17 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
Step 2-Use rvm to install the ruby Environment
$ rvm install 2.0.0
The same continues to wait for a long download and compilation process. After compilation, Ruby and Ruby gems will be installed.
Step 3-set the ruby version
After rvm is installed, run the following command to set the ruby of the specified version number to the default version number of the system.
$ rvm 2.0.0 --default
Similarly, other version numbers are enough, provided that you have installed the version number on rvm install.
At this time, you can try again to see if it is correct.
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin13.0.0] $ gem -v
2.1.6 $ gem source -r https://rubygems.org/ $ gem source -a https://ruby.taobao.org
Step 4-install the rails Environment
After the above three steps, the ruby environment is installed, and then the rails
$ gem install rails
Then, verify that the installation is correct.
$ rails -vRails 3.2.13
Start your ruby and rails journey.
Welcome to the ruby world!