Skip to content

Instantly share code, notes, and snippets.

@apprentice1988
Last active December 1, 2015 15:27
Show Gist options
  • Save apprentice1988/754920ce1fa2352a9737 to your computer and use it in GitHub Desktop.
Save apprentice1988/754920ce1fa2352a9737 to your computer and use it in GitHub Desktop.
配置DO
参考https://gorails.com/deploy/ubuntu/14.04和https://coderwall.com/p/yz8cha
把ip放入/etc/hosts 文件中, 比如demo: 123.23.3.4
=====================================
adduser jizilong
groupmod --new-name deploy jizilong # change group name
==================
visudo # edit previllege
#在Root下面添加新创建的user及其权限
Root ALL (ALL:ALL) ALL
jizilong ALL (ALL:ALL) ALL
============================
#给jizlong添加key, 让其可以免密码登录
cp /root/.ssh/authorized_keys /home/jizilong/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub | ssh deployer@72.14.183.209 'cat >> ~/.ssh/authorized_keys'
ssh-add # -K on Mac OS X
# change to jizilong@demo
#install go
wget https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz
tar xf go1.5.1.linux-amd64.tar.gz
echo "export GOROOT=\$HOME/go" >> ~/.profile
echo "PATH=$PATH:\$GOROOT/bin" >> ~/.profile
source .profile
go env
mkdir ~/.go
echo "export GOPATH=\$HOME/.go" >> .profile
echo "PATH=\$PATH:\$GOPATH/bin" >> .profile
source .profile
# installing go end
#install docker
follow official tutorial
sudo groupadd docker
sudo gpasswd -a jizilong docker
service docker restart
# add user to docker group in order to run docker without sudo
sudo apt-get update
sudo apt-get install git-core curl gcc libcurl4-openssl-dev # install git-core
# install ruby using rbenv
cd
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.2
rbenv global 2.1.2
ruby -v
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
# install pg
sudo apt-get install postgresql postgresql-server-dev-9.3
gem install pg -- --with-pg-config=/usr/bin/pg_config
# install bundler
gem install bundler
# install node
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get -y update
sudo apt-get -y install nodejs
#setup nginx
sudo apt-get install nginx
sudo service nginx start
# deployment
cap deploy:setup
# edit /home/deployer/apps/blog/shared/config/database.yml on server
cap deploy:cold
# puts ip into /etc/hosts file, eg: yummy: 123.2.3.4
#============ remote server
adduser jizilong
groupmod --new-name deploy jizilong
visudo
#puts jizilong ALL (ALL:ALL) ALL under root ALL...
cp /root/.ssh/authorized_keys /home/jizilong/.ssh/authorized_keys
apt-get -y update
apt-get install curl git-core python-software-properties
apt-get install nginx
service nginx start
apt-get install nodejs
apt-get install postgresql libpq-dev
sudo -u postgres psql
/postgres=# \postword
/postgres=# create user yummy password 'secret';
/postgres=# create database yummy_production owner yummy;
su jizilong
cd
sudo apt-get install rbenv ruby-build
#add below to .bashrc file
```
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
```
rbenv bootstrap-ubuntu-12-04 # using ubuntu 12.04
rbenv install 2.1.2
rbenv global 2.1.2
ruby -v
gem install bundler --no-ri --no-rdoc
rbenv rehash
bundle -v
#============= local terminal
cat ~/.ssh/id_rsa.pub | ssh jiizlong@yummy 'cat >> ~/.ssh/authorized_keys'
ssh-add # -K on Mac OS X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment