因为我折腾了好久,现在记录下我配置的过程
环境
VMWare Workstation 8.0
Ubuntu 12.04
时间
8/12/2013
主要参考
http://blog.sudobits.com/2012/05/02/how-to-install-ruby-on-rails-in-ubuntu-12-04-lts/
步骤
sudo apt-get update
sudo apt-get install mysql-server
输入root密码
$ sudo apt-get update
$ sudo apt-get install curl
$ sudo apt-get install git-core
curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
$ sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
sudo apt-add-repository ppa:chris-lea/node.js sudo apt-get update sudo apt-get install nodejs
$ rvm install 1.9.3
$ rvm --default use 1.9.3
$ ruby -v
$ gem -v
$ gem sources --remove https://rubygems.org/ $ gem sources -a http://ruby.taobao.org/ $ gem sources -l *** CURRENT SOURCES *** http://ruby.taobao.org
把源改到国内的淘宝
$ gem update --system
$ gem update
$ gem install rails
$ rails -v
sudo apt-get install libmysql-ruby libmysqlclient-dev #这个很重要
ok,可以开始建使用MYSQL的项目了
rails new demo -d mysql --skip-bundle
#修改 demo/Gemfile
#源改成 http://ruby.taobao.org
cd demo
bundle install
测试一下
#修改demo/config/database.yml
#填上密码,检查各项是否有误
rails g model Post content:string
bundle exec rake db:create
bundle exec rake db:migrate
可以看到结果
Over