Last active
December 19, 2015 12:39
-
-
Save yaoyi/5955999 to your computer and use it in GitHub Desktop.
rails deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# root用户 | |
# 更新系统 | |
apt-get -y update | |
apt-get -y install curl git-core python-software-properties | |
# 安装nginx | |
add-apt-repository ppa:nginx/stable | |
apt-get -y update | |
apt-get -y install nginx | |
service nginx start | |
# 安装Node.js | |
add-apt-repository ppa:chris-lea/node.js | |
apt-get -y update | |
apt-get -y install nodejs | |
#安装percona | |
apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A | |
#修改/etc/apt/sources.list | |
sed -i '$a\deb http://repo.percona.com/apt precise main' /etc/apt/sources.list | |
sed -i '$a\deb-src http://repo.percona.com/apt precise main' /etc/apt/sources.list | |
apt-get update | |
apt-get -y install percona-server-server-5.6 percona-server-client-5.6 --force-yes | |
#安装mysql开发库 | |
apt-get -y install libmysqlclient-dev --force-yes | |
# 添加部署用户 | |
groupadd admin | |
# adduser deployer --ingroup admin --disabled-password | |
useradd deployer -m -g admin -s /bin/bash | |
echo "deployer:deployer"| chpasswd | |
groupadd deployer | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 切换到deployer用户 su - deployer | |
# 安装ruby管理rbenv/rvm,以rbenv为例 | |
curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash | |
sed -i '1i\export RBENV_ROOT="${HOME}/.rbenv" \n if [ -d "${RBENV_ROOT}" ]; then \n export PATH="${RBENV_ROOT}/bin:${PATH}" \n eval "$(rbenv init -)" \n fi' ~/.bashrc | |
# 重载环境变量 | |
. ~/.bashrc | |
# 安装ruby及依赖 | |
rbenv bootstrap-ubuntu-12-04 | |
rbenv install 1.9.3-p429 | |
rbenv global 1.9.3-p429 | |
gem install bundler --no-ri --no-rdoc | |
rbenv rehash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
in=$1 | |
DEPLOY_TO=${in##to=} #production, vagrant | |
if [ -z ${DEPLOY_TO} ]; then | |
DEPLOY_TO='vagrant' | |
elif [ ${DEPLOY_TO} != 'production' ]; then | |
DEPLOY_TO='vagrant' | |
fi | |
echo "deploy to $DEPLOY_TO" | |
mina setup to=${DEPLOY_TO} | |
mina sudo_setup to=${DEPLOY_TO} | |
mina deploy to=${DEPLOY_TO} | |
mina nginx:reload to=${DEPLOY_TO} | |
mina god:start to=${DEPLOY_TO} | |
mina health to=${DEPLOY_TO} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment