Latest videos

Deploy a NodeJS/Mysql App into AMAZON AWS EC2 server using GIT Hook
Deploy a NodeJS/Mysql App into AMAZON AWS EC2 server using GIT Hook sssssssd 2 Views • 4 years ago

Here are the STEPS:

New instance:
video:
http://youtu.be/qUtq59N6ph4

ON AWS:
- Select an Amazon Machine Image (AMI):
Ubuntu Server 12.04.3 LTS: 64bits

- Launch new instance:
choose the Key pair to access via SSH

- Coonect to server:
Use the Putty with the key (PEM) and DNS (ip) information


ON THE SERVER:
- Install all server packages:

1 - install node.js:
-----------------------------
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

2 - Install GIT:
-----------------------------
sudo apt-get install git

3 - Install Forever:
-----------------------------
sudo npm install forever -g

4 - Install Apache and phpMyAdmin:
------------------------------------------------------
1 - sudo apt-get update
2 - sudo apt-get install apache2
3 - sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

these commands are used to configure MySQL db:
4 - sudo mysql_install_db
5 - sudo /usr/bin/mysql_secure_installation


6 - Install PHP: sudo apt-get install php5 libapache2-mod-php5
7 - Install PHPMyAdmin: sudo apt-get install phpmyadmin

8 - sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf.d

9 - sudo /etc/init.d/apache2 restart


ON AWS:
- On AWS EC2 console open the port 80 for HTTP

- Test Apache by visiting the IP via HTTP

- Test MySQL and phpMyAdmin

- Create the Database


On the SERVER:
- make a "repo" folder: mkdir repo_YOUR NAME

- initialized a new bare GIT repo on the repo_YOUR NAME folder by $: git init --bare

- go to the .ssh/ folder and open and edit "authorized_keys" file

- On your personal computer open your "id_rsa" file located in windoes in the path "C:\Users\YOUR_USER_NAME\.ssh\"

- copy the content your public key ssh-rsa "AAAAB3..." into the "authorized_keys" file in the server.

ON YOUR PERSONAL COMPUTER:
- Create a new remote by $: git remote add ANY_NAME ssh://ubuntu@YOUR_IP_SERVER/home/ubuntu/repo_fpid_do_not_delete/

- Using GIT push code into the AWS server


ON THE SEVER:
- Create a new Hook called "post-receive" with code:
#!/bin/sh

GIT_WORK_TREE=/home/ubuntu/www

export GIT_WORK_TREE

git checkout -f

- Make "post-receive" executable: chmod +x post-receive


ON YOUR PERSONAL COMPUTER:
- Push some code again.


ON AWS CONSOLE:
- Open the port your nodeJS is running

DONE!


This video is really useful:
http://www.youtube.com/watch?v=N-v_DBFbZxo

Cheers!