Configure node app on ubuntu 14.04 - nodox/aws GitHub Wiki
AWS EC2 ubuntu 14.04
======================================== Resources =================================================== https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-14-04 https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-14-04 https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-14-04
Start EC2 Instance
AWS: create new ec2 server, ubuntu 14.04 AWS: open port 80, 443 in AWS console in security group remote: $ chmod 400 <PATH_TO_PEM_FILE> remote: $ ssh -i "PATH_TO_PEM_FILE" [email protected] remote: $ touch ~/.bash_profile remote: $ ssh-keygen local: $ cat ~/.ssh/id_rsa.pub remote: $ vim ~/.ssh/authorized_keys (and paste key)
Install Nginx
remote: $ sudo apt-get update remote: $ sudo apt-get install nginx remote: $ sudo update-rc.d nginx defaults remote: $ sudo vim /etc/nginx/sites-available/default remote: ================= Add ====================
http {
server {
listen 80;
server_name localhost;
root <PATH_TO_APP_DIST>;
index index.html index.htm;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_cache_bypass $http_upgrade;
}
}
}
==============================================
remote: $ sudo service nginx restart
Install MongoDB
remote: $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 remote: $ echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list remote: $ sudo apt-get update remote: $ sudo apt-get install -y mongodb-org remote $ sudo service mongod start
Install git, nvm, pm2
remote: $ sudo apt-get install git remote: $ wget -qO- https://raw.githubusercontent.com/xtuple/nvm/master/install.sh | sudo bash remote: $ exit (or source bash_profile??) local: $ ssh USER@IP-ADDRESS remote: nvm install 6 remote: sudo npm install -g pm2
Add Kard project local: Specify server in staging.rb local: Specify server in production.rb local: $ cap staging deploy
======================================
Add your project (optional) remote: $ cd remote: $ git clone <REPO_URL> remote: $ cd <PROJECT_NAME> remote: $ pm2 <index.js / NODE_FILE> local: Check ip address
server: ssh [email protected]