今天在ubuntu上搭建了rails环境,为方便后续查阅,特此记录
1、更新软件包,安装必要的软件
sudo apt-get update
sudo apt-get upgrade
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
2、安装RVM 如果系统中存在多个版本ruby,使用RVM进行管理是不二之选
curl -L https://get.rvm.io | bash -s stable
这一步有时会报错,提示找不到公钥,这是签名验证没通过,根据提示,执行下面操作:
gpg --keyserver hkp://keys.gnupg.net --recv-keys
409B6B1796C275462A1703113804BB82D39DC0E3
3、载入RVM环境,如果新打开终端,此步可略过 source ~/.rvm/scripts/rvm
4、安装ruby rvm install 2.0.0
这一步有时候会有下面这样的报错:
Error running 'requirements_debian_update_system ruby-2.0.0-p386',
showing last 15 lines of /home/yangye/.rvm/log/1448033555_ruby-2.0.0-p386/update_system.log
++ case "${TERM:-dumb}" in
++ case "$1" in
++ [[ -t 2 ]]
++ return 1
++ printf %b 'There has been error while updating '\''apt-get'\'', please give it some time and try again later.
404 errors should be fixed for rvm to proceed. Check your sources configured in:
/etc/apt/sources.list
/etc/apt/sources.list.d/*.list
\n'
There has been error while updating 'apt-get', please give it some time and try again later.
404 errors should be fixed for rvm to proceed. Check your sources configured in:
/etc/apt/sources.list
/etc/apt/sources.list.d/*.list
++ return 100
Requirements installation failed with status: 100.
解决办法: 在安装ruby前先执行这条命令
rvm autolibs disable
5、设置默认ruby版本 rvm 2.0.0 --default
6、改gem的镜像源
gem source -r https://rubygems.org/ gem source -r https://ruby.taobao.org/
7、安装bundler gem install bundler
8、安装rails gem install rails
后续在使用中还会遇到其他问题,届时会继续补充