1. 准备安装时使用的库
$ sudo apt-get install gcc g++ build-essential libssl-dev libreadline5-dev zlib1g-dev linux-headers-generic
2. 下载Ruby1.9.2源码编译安装
$ wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p0.tar.gz (如果无法下载,可以选择:http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2- p0.tar.bz2,http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p0.zip) $ tar -xvzf ruby-1.9.2-p0.tar.gz $ cd ruby-1.9.2-p0/ $ ./configure –prefix=/usr/local/ruby $ make && sudo make install
3. 准备环境变量
$ sudo gedit /etc/environment
添加环境变量
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/ruby/bin"
注意:也可以修改/etc/profile文件,添加/usr/local/ruby/bin
4. 检查Ruby安装情况
$ruby -v
正常的话,ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
5. 创建关联
$ sudo ln -s /usr/local/ruby/bin/ruby /usr/local/bin/ruby $ sudo ln -s /usr/local/ruby/bin/gem /usr/bin/gem
如果 /usr/bin/目录下面存在符号连接gem,就删除gem。重新:
$ sudo ln -s /usr/local/ruby/bin/gem /usr/bin/gem
6. 安装Rails
$ sudo gem install tzinfo builder memcache-client rack rack-test erubis mail text-format bundler thor i18n $ sudo gem install rack-mount $ sudo gem install rails
耐心等待。。。。
7. 检查Rails安装情况
$ source /etc/environment$ rails –v
正常的话,Rails 3.0.7
8.如果采用mysql数据库
$sudo apt-get install mysql-server libmysqlclient-dev libmysql-ruby $sudo gem install mysql
如果采用sqlite数据库:
$sudo apt-get install libsqlite3-dev build-essential $sudo gem install sqlite3-ruby
9.如果要安装spree框架
$sudo gem install spree
10.创建应用测试
如果是mysql
$rails new xxx -d=mysql $cd xxx
development: adapter: mysql2 encoding: utf8 database: blog_development pool: 5 username: root password: socket: /tmp/mysql.sock
$ bundle install $ rake db:create $rails server // 或简写为 $rails s
环境配置完毕。
感谢:http://www.cnblogs.com/msblog/archive/2011/03/08/1977407.html