Build a rails development environment in Ubuntu 11.10

Source: Internet
Author: User
Tags ruby on rails
When building a rails Development Environment on Ubuntu, there are always some problems, so I will contribute to the establishment of the environment from start to end. We enabled rails to develop a 400 telephone platform.
1. Install the nodejs Library
Sudo apt-Get install nodejs

2. Install GCC, MySQL, and some libraries and update the system to the latest version.

Sudo apt-Get update
Sudo apt-Get upgrade
Sudo apt-Get dist-Upgrade
Sudo reboot # restart the instance ~~

3. Install rvm

After the machine is restarted, log on again and open a terminal window. Install curl and git for the rvm script. Curl is a tool that uses multiple protocols (such as HTTP or FTP) for data transmission. "Git is a free open-source distributed version control system that applies to small projects to very large projects, taking into account both speed and efficiency ." Git is the version control system selected by most Ruby on Rails developers.

1. $ sudo apt-Get install curl

2. $ sudo apt-Get install Git-core
Configure git
Git will be used in rvm scripts, and we will also use it in the second part of this tutorial. After installation, we need to spend some time configuring it. Easy configuration: you only need to provide a user name and email address.
$ Git config -- global user. Name "your name"
$ Git config -- global user. Email your-email@address.com
For example:
$ Git config -- global user. Name "John Doe"
$ Git config -- global user. Email johndoe@mail.com
Now we can install rvm. Rvm refers to the ruby version manager. "It is a command line tool that allows you to easily install, manage, and use multiple Ruby environments and their corresponding gem packages ." Run the following command to install the script. Rvm will be installed in the home directory of your current login user.
$ Bash <(curl-s https://rvm.beginrescueend.com/install/rvm)
Switch to the main directory and modify the user's bash settings file to ensure that the rvm script is loaded every time the user logs on.
1. $ cd
2. $ Vim. bashrc

Add the following lines to the end of your Bash settings file.
1. [[-s "$ home/. rvm/scripts/rvm"] &. "$ home/. rvm/scripts/rvm"

Use the following command line to manually reload the setting file in the current logon. You can also open a new terminal window to automatically load the setting file. In this way, the rvm command can be used.
1. $ source. bashrc

You can run the following command to check whether the rvm script can work.
1. $ type rvm | head-1

If everything works, the command returns "rvm is a function" (rvm is a function ). Otherwise, you can go to the "troubleshooting your install" section on the rvm website to find a solution.

3. Prepare for installing Ruby and rubygems

When compiling and installing Ruby and rubygems from the source code, rvm can conveniently view the dependency between software packages.
1. $ rvm notes

You can list the dependent packages required for the standard Ruby version and the commands for installing them. Some Packages may have been installed.

1. $ sudo apt-Get install build-essential bison OpenSSL libreadline6 libreadline6-dev curl Git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev Autoconf libc6-dev ncurses-Dev
4. Install Ruby and rubygems
Rvm also has a command to see which Ruby version can be installed. Run the following command to check which Ruby versions can be installed:
1. $ rvm List known

It takes some time to install the standard Ruby version because it needs to be compiled from the source code.
1. $ rvm install 1.9.2

Before using the installed Ruby, you need to set this version to the default version. I tried this several times earlier and cannot set it, which is slightly different from the help.
1. $ rvm -- default use 1.9.2

Check the ruby and rubygems versions to ensure proper installation.
1. $ ruby-V
2. $ gem-V

If necessary, manually update rubygems and other gems to be updated.
1. $ gem update -- System
2. $ gem update
5. Install rails

All rails are packaged in rails gem. Installing it is the easiest part of this tutorial. Use rubygems to install it, that is, the gem command. After the installation is complete, check the version to ensure that the installation is correct.
1. $ gem install rails
2. $ rails-V
If the relevant library is missing
Gem install execjs

Gem install therubyracer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.