Skip to content

Instantly share code, notes, and snippets.

@richarddong
Created April 28, 2012 18:57
Show Gist options
  • Save richarddong/2521307 to your computer and use it in GitHub Desktop.
Save richarddong/2521307 to your computer and use it in GitHub Desktop.
bash script for installing Rails environment on Ubuntu 12.04
#!/bin/bash
# bash script for installing Rails environment on Ubuntu 12.04 Desktop
#
# Some sources has been changed to mirrors in China mainland.
#
# To use this script, do this in your shell:
#
# $ curl -L https://raw.github.com/gist/2521307/install-rails-12-04-desktop.sh | bash
clear
sudo echo ""; echo "Root Privilege Acquired"
echo ""
echo "======================================="
echo "========= Installing Aptitude ========="
echo "======================================="
echo ""
sudo apt-get -y install aptitude
echo ""
echo "======================================="
echo "========= Updating Apt Source ========="
echo "======================================="
echo ""
sudo aptitude update
echo ""
echo "======================================="
echo "=========== Installing RVM ============"
echo "======================================="
echo ""
curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo -e '\n[[ -s ~/.rvm/scripts/rvm ]] && source ~/.rvm/scripts/rvm # Load RVM into a shell session *as a function*' >> ~/.bashrc
echo ""
echo "======================================="
echo "======= Installing Dependencies ======="
echo "======================================="
echo ""
rvm requirements
sudo aptitude -y install vim wget build-essential openssl libreadline6 libreadline6-dev git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
# rvm --skip-autoreconf pkg install readline
# rvm pkg install zlib
echo ""
echo "======================================="
echo "======== Installing Ruby 1.9.3 ========"
echo "======================================="
echo ""
sed -ie 's/ftp\.ruby-lang\.org\/pub/ruby\.taobao\.org\/mirrors/' ~/.rvm/config/db
rvm install 1.9.3 # --with-readline-dir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr
rvm use 1.9.3 --default
echo ""
echo "ruby version:"
ruby -v
echo ""
echo "gem version:"
gem -v
echo ""
echo "======================================="
echo "======== Replacing Gem Source ========="
echo "======================================="
echo ""
gem source -r http://rubygems.org/
gem source -r http://ruby.taobao.org
gem source -a http://ruby.taobao.org
echo ""
gem source -l
echo ""
echo "======================================="
echo "======= Install Bundler & Rails ======="
echo "======================================="
echo ""
gem install bundler rails
echo ""
bundle -v
echo ""
rails -v
source ~/.bashrc
echo ""
echo "======================================="
echo " CONGRATULATIONS! "
echo " INSTALLATION COMPLETED! "
echo ""
echo "If you met some problems during instal-"
echo "lation, please tell me on: "
echo " https://gist.github.com/2521307"
echo "======================================="
echo ""
#!/bin/bash
# bash script for installing Rails environment on Ubuntu 12.04 Server
#
# Some sources has been changed to mirrors in China mainland.
#
# To use this script, do this in your shell:
#
# $ curl -L https://raw.github.com/gist/2521307/install-rails-12-04-server.sh | bash
sudo echo ""; echo "Root Privilege Acquired"
echo ""
echo "======================================="
echo "========= Installing Aptitude ========="
echo "======================================="
echo ""
sudo apt-get -y install aptitude
echo ""
echo "======================================="
echo "=========== Installing RVM ============"
echo "======================================="
echo ""
curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo ""
echo "======================================="
echo "======= Installing Dependencies ======="
echo "======================================="
echo ""
(rvm requirements)
sudo aptitude -y install build-essential openssl libreadline6 libreadline6-dev git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
echo ""
echo "======================================="
echo "======== Installing Ruby 1.9.3 ========"
echo "======================================="
echo ""
rvm install 1.9.3
rvm use 1.9.3 --default
echo ""
echo "ruby version:"
ruby -v
echo ""
echo "gem version:"
gem -v
echo ""
echo "======================================="
echo "======== Replacing Gem Source ========="
echo "======================================="
echo ""
gem source -r http://rubygems.org/
gem source -r http://ruby.taobao.org
gem source -a http://ruby.taobao.org
echo ""
gem source -l
echo ""
echo "======================================="
echo "======= Install Bundler & Rails ======="
echo "======================================="
echo ""
gem install bundler rails
echo ""
bundle -v
echo ""
rails -v
echo ""
echo "======================================="
echo " CONGRATULATIONS! "
echo " INSTALLATION COMPLETED! "
echo ""
echo "If you met some problems during instal-"
echo "lation, please tell me on: "
echo " https://gist.github.com/2521307"
echo "======================================="
echo ""
@jonahchen
Copy link

在Ubuntu 12.04 64 server上运行这个脚本的时候会因为缺少『Missing required packages: libgdbm-dev, pkg-config, libffi-dev.』这些包而中断,导致无法用rvm安装ruby 1.9.3。建议加一行 rvm autolibs enable 命令,来让rvm自动下载缺失包。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment