RVM is a command-line tool that provides the management and switching of a convenient, multiple-version Ruby environment.
https://rvm.io/
If you are going to learn ruby/rails, RVM is one of the essential tools.
All commands here are operated under user privileges, and any command is best not to use sudo.
RVM Installation
$ curl-l Get.rvm.io | Bash-s Stable
$ source ~/.BASHRC
$ source ~/.bash_profile
Modify the RVM Ruby installation source to the domestic Taobao mirror server, which can improve the installation speed
$ sed-i-E ' s/ftp\.ruby-lang\.org\/pub\/ruby/ruby\.taobao\.org\/mirrors\/ruby/g ' ~/.rvm/config/db
Ruby Installation and switching
Listing known versions of Ruby
Install a Ruby version
The latest 2.2.0 is installed here and the RVM list known can be installed.
Toggle Ruby Version
If you want to set it as the default, this will be the default Ruby version of the new console that you open later
Query for Ruby already installed
Uninstall an installed version
The use of Gemset
RVM not only provides an environment in which multiple Ruby versions coexist, but can also manage different gemset depending on the project.
Gemset can be understood as an independent virtual GEM environment where each gemset is independent of each other.
For example, you have two projects, one is Rails 2.3 and one is RAILS3. Gemset can help you easily build two GEM development environment, and easy to switch.
Gemset is appended to the Ruby language version, for example, you used 1.9.2 to create a gemset called RAILS3, which RAILS3 does not exist when switching to 1.8.7.
Establish Gemset
RVM use 1.8.7
RVM gemset Create Rails23
You can then set the established Gemset as the current environment
Use can be used to toggle language or Gemset
The premise is that they have been installed (or established). And you can see it in the List command.
RVM use 1.8.7
RVM use 1.8.7@rails23
All the installed gems are then installed under this gemset.
Lists the current Ruby Gemset
Clear the Gem in the Gemset
If you want to clear all the gems of a gemset and want to reinstall all gems, you can do so
RVM Gemset Empty 1.8.7@rails23
Delete a Gemset
RVM Gemset Delete rails2-3
Project Auto Load Gemset
RVM can also load Gemset automatically.
For example, we have a Rails 3.1.3 project that requires a 1.9.3 version of Ruby, and the entire process can be this way.
RVM Install 1.9.3
RVM use 1.9.3 rvm gemset
Create rails313
RVM use 1.9.3@rails313
Enter the project directory below to create a. rvmrc file.
In this file you can simply add a command:
Then no matter what your current Ruby settings are, RVM will help you load Ruby 1.9.3 and rails313 Gemset when the CD gets to this project.
use RVM to quickly deploy Nginx + passenger
First install passenger
Then use Passenger-install-nginx-module to install Nginx and deployment.
Because this step requires root permissions (because to compile Nginx) you can use Rvmsudo this thing (this thing is really a good thing).
Rvmsudo Passenger-install-nginx-module
Then you will choose to download the Nginx source code automatically compiled installation, or choose their own Nginx source location.
Select Nginx manually installed can add other compilation parameters to facilitate custom compilation Nginx.
Then download the installation all the way. The default installation location is/opt/nginx.
Then look at the nginx.conf, all configured for you, just add the root position (yourapp/public) on it.
When I first installed it, I exclaimed, "That's awesome."
Ps:rvm is a good thing to do, smart, (most) after the failure of the operation will tell you the reason, and then tell you what to install the Lib and so on, very suitable for novice veteran use, is simply a home travel necessary medicine.