你需要经常安装部署 Rails 到新的 Web 服务器吗?
你是否还在经历每次从安装 Ruby Rubygems MySQL... 再到安装 Web Server 组件... 反复烦躁的安装流程呢?
现在你可以改用这个脚本实现在 Ubuntu Server 上面部署 Ruby1.8 + Rails + Passenger + Nginx 的环境:
#!/bin/sh
echo "=== YTRIPTHIRD UBUNTU INSTALL ==="
cd /tmp# Ruby
echo "=== Install Ruby library..."
sudo apt-get install g++ ruby1.8 rubygems rake irb ruby1.8-dev build-essential libopenssl-ruby imagemagick rmagick
echo "=== Ruby library install done."
echo ""
# MySQL Server
echo -n "Do you wan't install MySQL automatic[y/n]:"
read KEYcase $KEY iny|Y)
echo "=== Install MySQL server..."
sudo apt-get install mysql-server mysql
;;
esac
sudo apt-get install libmysqlclient-dev
echo "=== MySQL install done."
echo ""
# Rubygems
echo -n "Do you wan't install Rubygems?[y/n]:"
read KEYcase $KEY iny|Y)
echo "=== Install Rubygems from source file..."
wget
unzip rubygems-1.3.5.zip
cd rubygems-1.3.5 sudo ruby setup.rb sudo gem sources -a cd .. sudo rm -R /tmp/rubygems-1.3.5 echo "=== Rubygems install done."
;;
esac
echo ""
# Install Rails
echo -n "Do you wan't install Rails?[y/n]"
read KEYcase $KEY iny|Y)
echo "=== Install Rails and some Gems..."
sudo gem install rails passenger --no-rdoc
echo "=== Rails install done."
;;
esac
echo ""
# Install Web server
echo "=== Install Web Server"
wget
tar zxf nginx-0.7.64.tar.gz
echo ""
echo "===*** Nginx install Warring! ***==="
echo " *** nginx source path: /tmp/nginx-0.7.64 "
echo " *** must be install nginx in: /etc/nginx "
echo ""
sudo passenger-install-nginx-module
echo "=== Web Server install done."
echo ""
此脚本一在 Ubuntu Server 9.04 版本上面测试通过,不过可能有些时候需要对这个脚本做一些微调后方可适应你的环境,如 Ruby 的版本、Rails的版本...
或者你不想用 Passenger + Nginx 来部署你的 Rails App,也可以修改 Install Web Server 这段。
或者还可以在 第一段批处理的地方加入更多的类库安装....
总之,本脚本是给你一个参考例子,以后部署 Rails App 别再手动安装了,把你的安装过程整理到 Shell 脚本中去,然后:
$ sh install-ubuntu.sh
搞定所有流程,方便省事,又不用每次部署的时候反复的在 Google 上面查资料!