cd /usr/share/locales
sudo ./install-language-pack zh_CN
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libpq-dev imagemagick libmagickwand-dev
sudo apt-get install memcached redis-server nodejs
# https://www.linode.com/docs/databases/redis/redis-on-ubuntu-12-04-precise-pangolin
cp ~/.profile ~/.bash_profile
add following code to ~/.bash_profile
# ~/.profile: executed by Bourne-compatible login shells.
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
mesg n
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
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
rbenv install 2.1.3
rbenv global 2.1.3
ruby -v
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
# 如果上面失败,可以使用:
curl -#LO https://rvm.io/mpapis.asc
gpg --import mpapis.asc
$ curl -sSL https://get.rvm.io | bash -s stable
# 如果上面的连接失败,可以尝试:
$ curl -L https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
source ~/.rvm/scripts/rvm
# 检查一下是否安装正确
$ rvm -v
$ rvm install 2.3.0
$ rvm use 2.3.0 --default
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
sudo apt-get install apt-transport-https ca-certificates
sudo vim /etc/apt/sources.list.d/passenger.list
insert one of the following lines, depending on your distribution.
deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main
sudo chown root: /etc/apt/sources.list.d/passenger.list
sudo chmod 600 /etc/apt/sources.list.d/passenger.list
sudo apt-get update
sudo apt-get install nginx-extras passenger
Edit /etc/nginx/nginx.conf and uncomment and change to this
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/ubuntu/.rbenv/shims/ruby;
# passenger_friendly_error_pages on; for show error
cd /etc/nginx/sites-available
sudo vim virtual-host-name
server {
server_name virtual-host;
listen 80;
root /home/ubuntu/www/virtual_host_path/current/public;
passenger_enabled on;
rails_env staging; # ruby env
gzip on;
gzip_http_version 1.1;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_types text/plain text/css text/xml application/xml application/xml+rss;
location ~* \.(ico|css|gif|jp?g|png)(\?[0-9]+)?$ {
expires max;
}
}
sudo ln -nfs /etc/nginx/sites-available/virtual-host-name /etc/nginx/sites-enabled/virtual-host-name
gem install bundler
gem install whenever
sudo vim /etc/environment
添加 RAILS_ENV=production
mina deploy # 部署 staging 环境
mina deploy on=live # 部署 production 环境