现在所使用的ROR(Ruby on Rails)中Ruby我们都是采用rvm来管理的,但是每次在安装配置环境的时候都需要去执行一条条指令,所以干脆就自己写了个shell 脚本来帮助配置环境~
使用方式:
- 新建一个ruby.sh文件,
- 复制下面代码到ruby.sh中,
- 打开终端,并且切换到ruby.sh文件目录中:
- 执行sh ruby.sh
- 等待安装环境
代码:
echo "========== 安装函数库 ================="
sudo apt-get install curl bison build-essential git-core
sudo apt-get install zlib1g-dev libssl-dev libreadline5-dev libxml2-dev
echo "========== 安装rvm ==================="
mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone git://github.com/wayneeseguin/rvm.git && cd rvm && ./install
echo "========== 执行 vim ~/.bashrc ================="
echo "========== 并且将下面内容复制到.bashrc最后 ==========="
echo " if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
source "$HOME/.rvm/scripts/rvm";
fi
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
"
echo "========== 修改完后请按回车键继续: =========="
read var
echo "========= 安装ruby ==========="
rvm install 1.9.2
echo "======== 安装rails ==========="
gem install rails
echo "======= 安装mysql ============"
sudo apt-get install mysql-server
sudo apt-get install mysql-client
echo "====== 安装mysql驱动 ========="
sudo apt-get install libmysqlclient-dev
sudo gem install mysql2
echo "===== Ruby on rails 环境搭配成功(Mouse)!! ======== "