How To Install Ruby with rbenv on Cent OS 7.2
来源:互联网 发布:安卓富文本编辑器源码 编辑:程序博客网 时间:2024/06/05 08:19
[root@contoso ~]# yum install -y openssl-devel readline-devel zlib-devel
Now we are ready to install rbenv. Let's clone the rbenv repository from git. You should complete these steps from the user account from which you plan to run Ruby.
[root@contoso ~]# git clone https://github.com/rbenv/rbenv.git ~/.rbenv
From here, you should add ~/.rbenv/bin to your $PATH so that you can use rbenv's command line utility. Also adding ~/.rbenv/bin/rbenv init to your ~/.bash_profile will let you load rbenv automatically.
[root@contoso ~]# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
[root@contoso ~]# echo 'eval "$(rbenv init -)"' >> ~/.bashrc
Next, source rbenv by typing:
[root@contoso ~]# source ~/.bashrc
You can check to see if rbenv was set up properly by using the type command, which will display more information about rbenv:
[root@contoso ~]# type rbenv
Your terminal window should output the following:
Output
rbenv is a function
rbenv ()
{
local command;
command="$1";
if [ "$#" -gt 0 ]; then
shift;
fi;
case "$command" in
rehash | shell)
eval "$(rbenv "sh-$command" "$@")"
;;
*)
command rbenv "$command" "$@"
;;
esac
}
In order to use the rbenv install command, which simplifies the installation process for new versions of Ruby, you should install ruby-build, which we will install as a plugin for rbenv through git:
[root@contoso ~]# git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
At this point, you should have both rbenv and ruby-build installed, and we can move on to installing Ruby.
Install Ruby
With the ruby-build rbenv plugin now installed, we can install whatever versions of Ruby that we may need through a simple command. First, let's list all the available versions of Ruby:
[root@contoso ~]# rbenv install -l
The output of that command should be a long list of versions that you can choose to install.
We'll now install a particular version of Ruby. It's important to keep in mind that installing Ruby can be a lengthy process, so be prepared for the installation to take some time to complete.
As an example here, let's install Ruby version 2.3.1, and once it's done installing, we can set it as our default version with the global sub-command:
[root@contoso ~]# rbenv install 2.4.1
[root@contoso ~]# rbenv global 2.4.1
If you would like to install and use a different version, simply run the rbenv commands with a different version number, as in rbenv install 2.3.0 and rbenv global 2.3.0.
Verify that Ruby was properly installed by checking your version number:
[root@contoso ~]# rbenv global 2.4.1
If you installed version 2.4.1 of Ruby, your output to the above command should look something like this:
Output
[root@contoso ~]# ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
You now have at least one version of Ruby installed and have set your default Ruby version. Next, we will set up gems and Rails.
Working with Gems
Gems are packages that extend the functionality of Ruby. We will want to install Rails through the gem command.
So that the process of installing Rails is less lengthy, we will turn off local documentation for each gem we install. We will also install the bundler gem to manage application dependencies:
[root@contoso ~]# echo "gem: --no-document" > ~/.gemrc
[root@contoso ~]# gem install bundler
Fetching: bundler-1.15.4.gem (100%)
Successfully installed bundler-1.15.4
1 gem installed
You can use the gem env command (the subcommand env is short for environment) to learn more about the environment and configuration of gems. You can check the location where gems are being installed by using the home argument, which will show the pathway to where gems are installed on your server.
[root@contoso ~]# gem env home
Your output should look something like this, with root being the name of the user:
[root@contoso ~]# gem env home
/root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0
Uninstalling Ruby versions
[root@contoso ~]# rbenv uninstall 2.4.1
Now we are ready to install rbenv. Let's clone the rbenv repository from git. You should complete these steps from the user account from which you plan to run Ruby.
[root@contoso ~]# git clone https://github.com/rbenv/rbenv.git ~/.rbenv
From here, you should add ~/.rbenv/bin to your $PATH so that you can use rbenv's command line utility. Also adding ~/.rbenv/bin/rbenv init to your ~/.bash_profile will let you load rbenv automatically.
[root@contoso ~]# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
[root@contoso ~]# echo 'eval "$(rbenv init -)"' >> ~/.bashrc
Next, source rbenv by typing:
[root@contoso ~]# source ~/.bashrc
You can check to see if rbenv was set up properly by using the type command, which will display more information about rbenv:
[root@contoso ~]# type rbenv
Your terminal window should output the following:
Output
rbenv is a function
rbenv ()
{
local command;
command="$1";
if [ "$#" -gt 0 ]; then
shift;
fi;
case "$command" in
rehash | shell)
eval "$(rbenv "sh-$command" "$@")"
;;
*)
command rbenv "$command" "$@"
;;
esac
}
In order to use the rbenv install command, which simplifies the installation process for new versions of Ruby, you should install ruby-build, which we will install as a plugin for rbenv through git:
[root@contoso ~]# git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
At this point, you should have both rbenv and ruby-build installed, and we can move on to installing Ruby.
Install Ruby
With the ruby-build rbenv plugin now installed, we can install whatever versions of Ruby that we may need through a simple command. First, let's list all the available versions of Ruby:
[root@contoso ~]# rbenv install -l
The output of that command should be a long list of versions that you can choose to install.
We'll now install a particular version of Ruby. It's important to keep in mind that installing Ruby can be a lengthy process, so be prepared for the installation to take some time to complete.
As an example here, let's install Ruby version 2.3.1, and once it's done installing, we can set it as our default version with the global sub-command:
[root@contoso ~]# rbenv install 2.4.1
[root@contoso ~]# rbenv global 2.4.1
If you would like to install and use a different version, simply run the rbenv commands with a different version number, as in rbenv install 2.3.0 and rbenv global 2.3.0.
Verify that Ruby was properly installed by checking your version number:
[root@contoso ~]# rbenv global 2.4.1
If you installed version 2.4.1 of Ruby, your output to the above command should look something like this:
Output
[root@contoso ~]# ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
You now have at least one version of Ruby installed and have set your default Ruby version. Next, we will set up gems and Rails.
Working with Gems
Gems are packages that extend the functionality of Ruby. We will want to install Rails through the gem command.
So that the process of installing Rails is less lengthy, we will turn off local documentation for each gem we install. We will also install the bundler gem to manage application dependencies:
[root@contoso ~]# echo "gem: --no-document" > ~/.gemrc
[root@contoso ~]# gem install bundler
Fetching: bundler-1.15.4.gem (100%)
Successfully installed bundler-1.15.4
1 gem installed
You can use the gem env command (the subcommand env is short for environment) to learn more about the environment and configuration of gems. You can check the location where gems are being installed by using the home argument, which will show the pathway to where gems are installed on your server.
[root@contoso ~]# gem env home
Your output should look something like this, with root being the name of the user:
[root@contoso ~]# gem env home
/root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0
Uninstalling Ruby versions
[root@contoso ~]# rbenv uninstall 2.4.1
阅读全文
0 0
- How To Install Ruby with rbenv on Cent OS 7.2
- How to Install Ruby on Rails on Ubuntu 12.04 LTS (Precise Pangolin) with RVM
- How to Install PyQt4 on OS X
- Install JDK on the Cent Os 6.2
- How to install Ruby on Rails in Ubuntu 11.10
- How To Install ruby-oci8 on Ubuntu Desktop 64bits
- How to install subclipse on Mac OS X
- How to Install Subversion on Mac OS X
- How to install and run Chromium OS on VMware Player
- How To Install MongoDB On Mac OS X
- How to install Maven on Mac OS X Mavericks (10.9)
- How to Install PHP intl extension on OS X
- How to install OS X Mavericks in Virtualbox with Niresh
- How to Install Apache Tomcat 8 (on Windows, Mac OS X, Ubuntu) and Get Started with Java Servlet Prog
- how to test observe with rspec in ruby on rails.
- How To Install On Debian with Several Codecs
- How to Install RSyslog+MySQL with LogAnalyzer on CentOS
- How to install Microsoft Office 2010 on Linux with Wine
- 区间LCM
- spring第一天
- 数据库索引的实现原理
- OPENCV图像边缘查找与分割技术在android中使用汇总
- hdu4614 Vases and Flowers (线段树)
- How To Install Ruby with rbenv on Cent OS 7.2
- ubuntu systemctl generated and enabled
- [kaggle数据] 泰坦尼克号生存预测分析
- Oracle存储过程基本语法及基础教程
- 计算机系大学生、程序员怎么在空余时间赚钱
- LeetCode:595 Big Countions
- C#--抽象工厂设计模式原理
- 无穷小放飞互联网行动即将开始!
- vs---编写第一个JavaScript程序