ubuntu安装ruby on rails 环境

1,首先要换成阿里的源。并且gem apt-get update更新下源

2,安装依赖包:

  1. sudo apt-get install -y build-essential openssl curl libcurl3-dev libreadline6 libreadline6-dev git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf automake libtool imagemagick libmagickwand-dev libpcre3-dev libsqlite3-dev

 3,安装rbenv

cd

git clone git://github.com/sstephenson/rbenv.git .rbenv

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc

echo 'eval "$(rbenv init -)"' >> ~/.bashrc

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc

exec $SHELL

 4,安装ruby


rbenv install 2.2.2

rbenv global 2.2.2

rbenv rehash

5,换成淘宝源安装rails。

  gem sources --remove https://rubygems.org/

 gem sources -a https://ruby.taobao.org/

echo "gem: --no-ri --no-rdoc" > ~/.gemrc

gem install rails -V 

rbenv rehash # 导出 gem 中提供的系统命令

6,查看rails版本

rails -v

7,安装mysql

sudo apt-get install mysql-server  mysql-client  libmysqlclient-dev

你可能感兴趣的:(ubuntu安装ruby on rails 环境)