Ubuntu下搭建Ruby On Rails开发环境

Ubuntu 12.04 + Ruby 2.0 + Rails 3.2.13


1、安装系统需要的包

$ sudo apt-get install -y build-essential openssl curl libcurl3-dev libreadline6 libreadline6-dev git zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf automake libtool imagemagick libmagickwand-dev libpcre3-dev libsqlite3-dev libmysql-ruby libmysqlclient-dev


2、安装RVM

$ curl -L https://get.rvm.io | bash -s stable

安装RVM成功后,
然后,载入 RVM 环境(新开 Termal 就不用这么做了,会自动重新载入的)

$ source ~/.rvm/scripts/rvm

检查一下是否安装正确

$ rvm -v
rvm 1.17.3 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]


3、用RVM安装Ruby环境

# 替换 Ruby 下载地址到国内淘宝镜像服务器$ sed -i.bak 's!ftp.ruby-lang.org/pub/ruby!ruby.taobao.org/mirrors/ruby!' $rvm_path/config/db
# 安装 readline 包$ rvm pkg install readline
# 安装 Ruby 2.0.0$ rvm install 2.0.0 --with-readline-dir=$rvm_path/usr


4、设置Ruby版本

$ rvm 2.0.0 --default

测试是否正确

$ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474)[x86_64-darwin12.3.0]
$ gem -v
2.0.0
$ gem source -r https://rubygems.org/
$ gem source -a http://ruby.taobao.org


5、安装Rails环境

$ gem install bundler rails #或者gem install -v=3.2.13 rails

测试安装是否正确

$ bundle -v
Bundler version 1.0
$ rails -v
Rails 3.2.13


6、安装MySQL

$ sudo apt-get install mysql-server mysql-client //牢记安装过程中输入的密码$ sudo apt-get install libmysql-ruby libmysqlclient-dev
$ gem install mysql2

查看Gem包 gem list



参考自:http://ruby-china.org/wiki/install_ruby_guide


你可能感兴趣的:(ubuntu,Rails)