Skip to content

Instantly share code, notes, and snippets.

@lucduong
Created December 2, 2016 03:12
Show Gist options
  • Save lucduong/8fad64356e23cfc311e98bcd3554f954 to your computer and use it in GitHub Desktop.
Save lucduong/8fad64356e23cfc311e98bcd3554f954 to your computer and use it in GitHub Desktop.

FUEL STAGING

Instance ID: i-9ba4e4a3

Public DNS

ec2-54-222-135-157.cn-north-1.compute.amazonaws.com.cn

Public IP

54.222.135.157

ssh -i "~/.ssh/fuel-staging.pem" ec2-user@54.222.135.157

Add deployer user

sudo adduser deployer

Copy public key from local PC

cat ~/.ssh/id_rsa.pub

And then copy the key you see

Switch to the deployer account so that newly created files have the proper ownership.

sudo su - deployer

Create a .ssh directory for the authorized_keys file

mkdir .ssh

Change the file permissions of the .ssh directory to 700 (this means only the file owner can read, write, or open the directory).

chmod 700 .ssh

Create a file named "authorized_keys" in the .ssh directory.

touch .ssh/authorized_keys

Change the file permissions of the authorized_keys file to 600 (this means only the file owner can read or write to the file).

Important
	This step is very important; without these exact file permissions, you will not be able to log into this account using SSH.

chmod 600 .ssh/authorized_keys

Edit the authorized_keys file with your favorite text editor and paste the public key for your key pair into the file, for example:

nano ~/.ssh/authorized_keys

And now paste the public key you copied from local PC

From now on, you can access to deployer by using ssh

ssh deployer@54.222.135.157

Generate SSH Key if not existed yet

ssh-keygen -t rsa -C "nykfuel-staging-server"

Add to github

Install development tools

yum groupinstall "Development Tools"

yum install git pcre pcre-devel

yum install postgresql94-devel

yum install -y openssl-devel readline-devel zlib-devel

Install oh my zsh (Optional)

ssh ec2-user@54.222.135.157

sudo yum update

sudo yum install zsh

exit

ssh deployer@54.222.135.157

wget --no-check-certificate http://install.ohmyz.sh -O - | sh

chsh -s /bin/zsh

exit

ssh deployer@54.222.135.157

Install rbenv

git clone git://github.com/sstephenson/rbenv.git /home/deployer/.rbenv

Create the following file:

nano /etc/profile.d/rbenv.sh

Paste below code and then save

export RBENV_ROOT=/home/deployer/.rbenv
export PATH="${RBENV_ROOT}/bin:$PATH"
eval "$(rbenv init -)"

Install ruby-build

. /etc/profile

git clone https://github.com/sstephenson/ruby-build.git /home/deployer/.rbenv/plugins/ruby-build

Install Ruby 2.2.3

rbenv install 2.2.3

Make this version become global version

rbenv global 2.2.3 rbenv rehash

When you use Amazon Linux (China)

gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/

To check the current source

gem sources -l

*** CURRENT SOURCES ***

https://ruby.taobao.org

####Install bundler gem update --system

gem install bundler

And...

bundle config mirror.https://rubygems.org https://ruby.taobao.org

Install NodeJs

  1. If CentOS

yum install -y epel-release

yum install nodejs npm --enablerepo=epel

  1. If Linux

yum install nodejs npm

Install nginx

yum install nginx

sudo service nginx start

Change the configuration file

/etc/sysconfig/nginx

/etc/init.d/nginx

Configuration

sudo nano /etc/init.d/nykfuel-staging

Paste configuration of unicorn.sh and save.

sudo chown deployer:deployer /etc/init.d/nykfuel-staging

CHMOD

sudo chmod 755 /etc/init.d/nykfuel-staging

Make new dir

sudo mkdir /var/www

sudo chown -R ec2-user:ec2-user /var/www/

PATH=$PATH:$HOME/bin:/usr/pgsql-9.4/bin

FOR CentOS

which pg_config

/usr/pgsql-9.4/bin/pg_config

bundle config build.pg --with-pg-config=/usr/pgsql-9.4/bin/pg_config

For GitLabCI Runner

yum install libicu-devel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment