Login to your Amazon EC2 server and execute the following commands.
Install NodeJS
|
$: sudo apt-get update
$: sudo apt-get install -y python-software-properties python g++ make
$: sudo add-apt-repository ppa:chris-lea/node.js
$: sudo apt-get update
$: sudo apt-get install nodejs
$: sudo apt-get install git
$: sudo npm install forever -g
|
Initialize the remote git repo
|
$: cd ~/
$: mkdir repo/
$: cd repo
$: git init --bare
|
Configure hooks
|
$: cd repo/hooks/
$: cat > post-receive
#!/bin/sh
GIT_WORK_TREE=/home/ec2-user/www
export GIT_WORK_TREE
git checkout -f
cd $HOME/www
./start.sh
|
Automate the deployment process
|
$: mkdir www/
$: cd ~/www/
$: cat > start.sh
# this file is execute by post-receive everytime a Git Commit is made
# Path: /home/ec2-user/repo/hooks/post-receive
forever stopall
NODE_ENV='production' forever start server
|
Copy content of C:\Users\\.ssh\id_rsa.pub to remote Machine at .ssh folder
|
$: sudo vi .ssh/authorized_keys
|
Add the following line to Local Machine (dist/.git/config)
|
[remote "origin"]
url = ssh://ec2-user@<YOUR_SERVER_IP>/home/ec2-user/repo
fetch = +refs/heads/*:refs/remotes/repo/*
puttykeyfile = C:\\Users\\<YOUR_USERNAME>\\.ssh\\aws.ppk
|
Open http port from ec2 dashboard
Check with the command NODE_ENV=production node server
Configure IP tables to redirect all incoming connections to port 8080
|
$: sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
$: sudo iptables -t nat -L -n --line-number
|
Install MongoDB at amazon-ec2
How to install mongodb on amazon
No comments:
Post a Comment