Expand file tree
/
Copy pathec2
/Directory actions
More options
More optionsDirectory actions
More options
More options/
Copy pathec2
/Folders and files
| Name | Name | Last commit date | |
|---|---|---|---|
parent directory.. | |||
<!DOCTYPE HTML>
<html lang="en-US" manifest="../manifest.appcache">
<head>
<meta charset="UTF-8">
<title>EC2 | Full Stack JavaScript Engineering</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="generator" content="GitBook 0.5.2">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
<meta name="author" content="ivanoats">
<link rel="prev" href="../auth_auth/angular_jwt_basic.html" />
</head>
<body>
<link rel="stylesheet" href="../gitbook/style.css">
<div class="book" data-github="ivanoats/Full-Stack-JavaScript-Engineering" data-level="15" data-basepath=".." data-revision="1403537617260">
<div class="book-header">
<!-- Actions Left -->
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
<a href="https://github.com/ivanoats/Full-Stack-JavaScript-Engineering" target="_blank" class="btn pull-left home-bookmark" aria-label="GitHub home"><i class="fa fa-bookmark-o"></i></a>
<a href="#" class="btn pull-left toggle-search" aria-label="Toggle search"><i class="fa fa-search"></i></a>
<span id="font-settings-wrapper">
<a href="#" class="btn pull-left toggle-font-settings" aria-label="Toggle font settings"><i class="fa fa-font"></i>
</a>
<div class="dropdown-menu font-settings">
<div class="dropdown-caret">
<span class="caret-outer"></span>
<span class="caret-inner"></span>
</div>
<div class="btn-group btn-block">
<button id="reduce-font-size" class="btn btn-default">A</button>
<button id="enlarge-font-size" class="btn btn-default">A</button>
</div>
<ul class="list-group font-family-list">
<li class="list-group-item" data-font="0">Serif</li>
<li class="list-group-item" data-font="1">Sans</li>
</ul>
<div class="btn-group btn-group-xs btn-block color-theme-list">
<button type="button" class="btn btn-default" id="color-theme-preview-0" data-theme="0">White</button>
<button type="button" class="btn btn-default" id="color-theme-preview-1" data-theme="1">Sepia</button>
<button type="button" class="btn btn-default" id="color-theme-preview-2" data-theme="2">Night</button>
</div>
</div>
</span>
<!-- Actions Right -->
<a href="#" target="_blank" class="btn pull-right google-plus-sharing-link sharing-link" data-sharing="google-plus" aria-label="Share on Google Plus"><i class="fa fa-google-plus"></i></a>
<a href="#" target="_blank" class="btn pull-right facebook-sharing-link sharing-link" data-sharing="facebook" aria-label="Share on Facebook"><i class="fa fa-facebook"></i></a>
<a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="twitter" aria-label="Share on Twitter"><i class="fa fa-twitter"></i></a>
<a href="https://github.com/ivanoats/Full-Stack-JavaScript-Engineering/stargazers" target="_blank" class="btn pull-right count-star hidden-xs"><i class="fa fa-star-o"></i> Star (<span>-</span>)</a>
<a href="https://github.com/ivanoats/Full-Stack-JavaScript-Engineering/watchers" target="_blank" class="btn pull-right count-watch hidden-xs"><i class="fa fa-eye"></i> Watch (<span>-</span>)</a>
<!-- Title -->
<h1>
<i class="fa fa-spinner fa-spin"></i>
<a href="../" >Full Stack JavaScript Engineering</a>
</h1>
</div>
<div class="book-summary">
<div class="book-search">
<input type="text" placeholder="Search" class="form-control" />
</div>
<ul class="summary">
<li>
<a href="https://www.codefellows.org/full-stack-javascript-development-accelerator" target="blank" class="author-link">About the author</a>
</li>
<li>
<a href="https://github.com/ivanoats/Full-Stack-JavaScript-Engineering/issues" target="blank"class="issues-link">Questions and Issues</a>
</li>
<li>
<a href="https://github.com/ivanoats/Full-Stack-JavaScript-Engineering/edit/master/ec2/README.md" target="blank" class="contribute-link">Edit and Contribute</a>
</li>
<li class="divider"></li>
<li data-level="0" data-path="index.html">
<a href="../"><i class="fa fa-check"></i> Introduction</a>
</li>
<li class="chapter " data-level="1" data-path="pre-work/README.html">
<a href="../pre-work/README.html">
<i class="fa fa-check"></i> <b>1.</b> Prework
</a>
</li>
<li class="chapter " data-level="2" data-path="communication/connect_to_irc.html">
<a href="../communication/connect_to_irc.html">
<i class="fa fa-check"></i> <b>2.</b> Connect to IRC
</a>
</li>
<li class="chapter " data-level="3" data-path="day1/README.html">
<a href="../day1/README.html">
<i class="fa fa-check"></i> <b>3.</b> Day One
</a>
<ul class="articles">
<li class="chapter " data-level="3.1" data-path="day1/ToolsOverview.html">
<a href="../day1/ToolsOverview.html">
<i class="fa fa-check"></i> <b>3.1.</b> JavaScript Tools Overview
</a>
</li>
<li class="chapter " data-level="3.2" data-path="day1/pull_request_practice.html">
<a href="../day1/pull_request_practice.html">
<i class="fa fa-check"></i> <b>3.2.</b> Github Pull Request Practice
</a>
</li>
<li class="chapter " data-level="3.3" data-path="day1/computer_setup.html">
<a href="../day1/computer_setup.html">
<i class="fa fa-check"></i> <b>3.3.</b> Computer Setup
</a>
</li>
<li class="chapter " data-level="3.4" data-path="day1/initial_toolchain_practice.html">
<a href="../day1/initial_toolchain_practice.html">
<i class="fa fa-check"></i> <b>3.4.</b> Make sure grunt works
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="4" data-path="day2/README.html">
<a href="../day2/README.html">
<i class="fa fa-check"></i> <b>4.</b> Day Two
</a>
<ul class="articles">
<li class="chapter " data-level="4.1" data-path="day2/async_demo.html">
<a href="../day2/async_demo.html">
<i class="fa fa-check"></i> <b>4.1.</b> Async Demo
</a>
</li>
<li class="chapter " data-level="4.2" data-path="day2/hello_express.html">
<a href="../day2/hello_express.html">
<i class="fa fa-check"></i> <b>4.2.</b> Hello Express
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="5" data-path="day3/README.html">
<a href="../day3/README.html">
<i class="fa fa-check"></i> <b>5.</b> Day Three
</a>
<ul class="articles">
<li class="chapter " data-level="5.1" data-path="day3/responsive.html">
<a href="../day3/responsive.html">
<i class="fa fa-check"></i> <b>5.1.</b> Responsive Web Design
</a>
</li>
<li class="chapter " data-level="5.2" data-path="day3/Grunt.html">
<a href="../day3/Grunt.html">
<i class="fa fa-check"></i> <b>5.2.</b> Grunt
</a>
</li>
<li class="chapter " data-level="5.3" data-path="day3/Personal_Blog_Site_Tutorial_with_Yeoman_and_Zurb.html">
<a href="../day3/Personal_Blog_Site_Tutorial_with_Yeoman_and_Zurb.html">
<i class="fa fa-check"></i> <b>5.3.</b> Personal Blog Site Tutorial with Yeoman and Zurb
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="6" data-path="day4/README.html">
<a href="../day4/README.html">
<i class="fa fa-check"></i> <b>6.</b> Day Four
</a>
<ul class="articles">
<li class="chapter " data-level="6.1" data-path="day4/acceptance_testing_with_casperjs.html">
<a href="../day4/acceptance_testing_with_casperjs.html">
<i class="fa fa-check"></i> <b>6.1.</b> Acceptance Testing with CasperJS
</a>
</li>
<li class="chapter " data-level="6.2" data-path="day4/Sass.html">
<a href="../day4/Sass.html">
<i class="fa fa-check"></i> <b>6.2.</b> Sass
</a>
</li>
<li class="chapter " data-level="6.3" data-path="day4/Heroku.html">
<a href="../day4/Heroku.html">
<i class="fa fa-check"></i> <b>6.3.</b> Heroku
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="7" data-path="day5/README.html">
<a href="../day5/README.html">
<i class="fa fa-check"></i> <b>7.</b> Day Five
</a>
</li>
<li class="chapter " data-level="8" data-path="day6/README.html">
<a href="../day6/README.html">
<i class="fa fa-check"></i> <b>8.</b> Day Six
</a>
<ul class="articles">
<li class="chapter " data-level="8.1" data-path="day6/day6_readings.html">
<a href="../day6/day6_readings.html">
<i class="fa fa-check"></i> <b>8.1.</b> Readings
</a>
</li>
<li class="chapter " data-level="8.2" data-path="day6/Browserify.html">
<a href="../day6/Browserify.html">
<i class="fa fa-check"></i> <b>8.2.</b> Browserify
</a>
</li>
<li class="chapter " data-level="8.3" data-path="day6/Browserify_lab.html">
<a href="../day6/Browserify_lab.html">
<i class="fa fa-check"></i> <b>8.3.</b> Browserify lab
</a>
</li>
<li class="chapter " data-level="8.4" data-path="day6/requirejs.html">
<a href="../day6/requirejs.html">
<i class="fa fa-check"></i> <b>8.4.</b> Require.js
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="9" data-path="day7/README.html">
<a href="../day7/README.html">
<i class="fa fa-check"></i> <b>9.</b> Day Seven
</a>
<ul class="articles">
<li class="chapter " data-level="9.1" data-path="day7/unit_testing.html">
<a href="../day7/unit_testing.html">
<i class="fa fa-check"></i> <b>9.1.</b> Unit Testing
</a>
</li>
<li class="chapter " data-level="9.2" data-path="day7/REST.html">
<a href="../day7/REST.html">
<i class="fa fa-check"></i> <b>9.2.</b> REST
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="10" data-path="day8/README.html">
<a href="../day8/README.html">
<i class="fa fa-check"></i> <b>10.</b> Day Eight
</a>
<ul class="articles">
<li class="chapter " data-level="10.1" data-path="day8/superagent_testing.html">
<a href="../day8/superagent_testing.html">
<i class="fa fa-check"></i> <b>10.1.</b> Test With Super Agent
</a>
</li>
<li class="chapter " data-level="10.2" data-path="day8/mongo_mongoose_and_the_rest.html">
<a href="../day8/mongo_mongoose_and_the_rest.html">
<i class="fa fa-check"></i> <b>10.2.</b> Mongo, Mongoose and the REST
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="11" data-path="day9/README.html">
<a href="../day9/README.html">
<i class="fa fa-check"></i> <b>11.</b> Day Nine
</a>
<ul class="articles">
<li class="chapter " data-level="11.1" data-path="day9/ajax.html">
<a href="../day9/ajax.html">
<i class="fa fa-check"></i> <b>11.1.</b> AJAX
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="12" data-path="day10/README.html">
<a href="../day10/README.html">
<i class="fa fa-check"></i> <b>12.</b> Day Ten
</a>
</li>
<li class="chapter " data-level="13" data-path="ember/README.html">
<a href="../ember/README.html">
<i class="fa fa-check"></i> <b>13.</b> Ember
</a>
</li>
<li class="chapter " data-level="14" data-path="auth_auth/README.html">
<a href="../auth_auth/README.html">
<i class="fa fa-check"></i> <b>14.</b> Auth
</a>
<ul class="articles">
<li class="chapter " data-level="14.1" data-path="auth_auth/basic_authentication.html">
<a href="../auth_auth/basic_authentication.html">
<i class="fa fa-check"></i> <b>14.1.</b> Server Auth
</a>
</li>
<li class="chapter " data-level="14.2" data-path="auth_auth/angular_jwt_basic.html">
<a href="../auth_auth/angular_jwt_basic.html">
<i class="fa fa-check"></i> <b>14.2.</b> Angular Client Auth
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="15" data-path="ec2/README.html">
<a href="../ec2/README.html">
<i class="fa fa-check"></i> <b>15.</b> EC2
</a>
</li>
<li class="divider"></li>
<li>
<a href="http://www.gitbook.io/" target="blank" class="gitbook-link">Generated using GitBook</a>
</li>
</ul>
</div>
<div class="book-body">
<div class="body-inner">
<div class="page-wrapper" tabindex="-1">
<div class="book-progress">
<div class="bar">
<div class="inner" style="width: 100%;min-width: 97.36842105263158%;"></div>
</div>
<div class="chapters">
<a href="../index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a>
<a href="../pre-work/README.html" title="Prework" class="chapter done new-chapter" data-progress="1" style="left: 2.6315789473684212%;"></a>
<a href="../communication/connect_to_irc.html" title="Connect to IRC" class="chapter done new-chapter" data-progress="2" style="left: 5.2631578947368425%;"></a>
<a href="../day1/README.html" title="Day One" class="chapter done new-chapter" data-progress="3" style="left: 7.894736842105263%;"></a>
<a href="../day1/ToolsOverview.html" title="JavaScript Tools Overview" class="chapter done " data-progress="3.1" style="left: 10.526315789473685%;"></a>
<a href="../day1/pull_request_practice.html" title="Github Pull Request Practice" class="chapter done " data-progress="3.2" style="left: 13.157894736842104%;"></a>
<a href="../day1/computer_setup.html" title="Computer Setup" class="chapter done " data-progress="3.3" style="left: 15.789473684210526%;"></a>
<a href="../day1/initial_toolchain_practice.html" title="Make sure grunt works" class="chapter done " data-progress="3.4" style="left: 18.42105263157895%;"></a>
<a href="../day2/README.html" title="Day Two" class="chapter done new-chapter" data-progress="4" style="left: 21.05263157894737%;"></a>
<a href="../day2/async_demo.html" title="Async Demo" class="chapter done " data-progress="4.1" style="left: 23.68421052631579%;"></a>
<a href="../day2/hello_express.html" title="Hello Express" class="chapter done " data-progress="4.2" style="left: 26.31578947368421%;"></a>
<a href="../day3/README.html" title="Day Three" class="chapter done new-chapter" data-progress="5" style="left: 28.94736842105263%;"></a>
<a href="../day3/responsive.html" title="Responsive Web Design" class="chapter done " data-progress="5.1" style="left: 31.57894736842105%;"></a>
<a href="../day3/Grunt.html" title="Grunt" class="chapter done " data-progress="5.2" style="left: 34.21052631578947%;"></a>
<a href="../day3/Personal_Blog_Site_Tutorial_with_Yeoman_and_Zurb.html" title="Personal Blog Site Tutorial with Yeoman and Zurb" class="chapter done " data-progress="5.3" style="left: 36.8421052631579%;"></a>
<a href="../day4/README.html" title="Day Four" class="chapter done new-chapter" data-progress="6" style="left: 39.473684210526315%;"></a>
<a href="../day4/acceptance_testing_with_casperjs.html" title="Acceptance Testing with CasperJS" class="chapter done " data-progress="6.1" style="left: 42.10526315789474%;"></a>
<a href="../day4/Sass.html" title="Sass" class="chapter done " data-progress="6.2" style="left: 44.73684210526316%;"></a>
<a href="../day4/Heroku.html" title="Heroku" class="chapter done " data-progress="6.3" style="left: 47.36842105263158%;"></a>
<a href="../day5/README.html" title="Day Five" class="chapter done new-chapter" data-progress="7" style="left: 50%;"></a>
<a href="../day6/README.html" title="Day Six" class="chapter done new-chapter" data-progress="8" style="left: 52.63157894736842%;"></a>
<a href="../day6/day6_readings.html" title="Readings" class="chapter done " data-progress="8.1" style="left: 55.26315789473684%;"></a>
<a href="../day6/Browserify.html" title="Browserify" class="chapter done " data-progress="8.2" style="left: 57.89473684210526%;"></a>
<a href="../day6/Browserify_lab.html" title="Browserify lab" class="chapter done " data-progress="8.3" style="left: 60.526315789473685%;"></a>
<a href="../day6/requirejs.html" title="Require.js" class="chapter done " data-progress="8.4" style="left: 63.1578947368421%;"></a>
<a href="../day7/README.html" title="Day Seven" class="chapter done new-chapter" data-progress="9" style="left: 65.78947368421052%;"></a>
<a href="../day7/unit_testing.html" title="Unit Testing" class="chapter done " data-progress="9.1" style="left: 68.42105263157895%;"></a>
<a href="../day7/REST.html" title="REST" class="chapter done " data-progress="9.2" style="left: 71.05263157894737%;"></a>
<a href="../day8/README.html" title="Day Eight" class="chapter done " data-progress="10" style="left: 73.6842105263158%;"></a>
<a href="../day8/superagent_testing.html" title="Test With Super Agent" class="chapter done " data-progress="10.1" style="left: 76.3157894736842%;"></a>
<a href="../day8/mongo_mongoose_and_the_rest.html" title="Mongo, Mongoose and the REST" class="chapter done " data-progress="10.2" style="left: 78.94736842105263%;"></a>
<a href="../day9/README.html" title="Day Nine" class="chapter done " data-progress="11" style="left: 81.57894736842105%;"></a>
<a href="../day9/ajax.html" title="AJAX" class="chapter done " data-progress="11.1" style="left: 84.21052631578948%;"></a>
<a href="../day10/README.html" title="Day Ten" class="chapter done " data-progress="12" style="left: 86.84210526315789%;"></a>
<a href="../ember/README.html" title="Ember" class="chapter done " data-progress="13" style="left: 89.47368421052632%;"></a>
<a href="../auth_auth/README.html" title="Auth" class="chapter done " data-progress="14" style="left: 92.10526315789474%;"></a>
<a href="../auth_auth/basic_authentication.html" title="Server Auth" class="chapter done " data-progress="14.1" style="left: 94.73684210526316%;"></a>
<a href="../auth_auth/angular_jwt_basic.html" title="Angular Client Auth" class="chapter done " data-progress="14.2" style="left: 97.36842105263158%;"></a>
<a href="../ec2/README.html" title="EC2" class="chapter done " data-progress="15" style="left: 100%;"></a>
</div>
</div>
<div class="page-inner">
<section class="normal" id="section-gitbook_37">
<h1 id="how-to-host-a-nodejs-app-on-an-ec2-ubuntu-server">How to host a NodeJS app on an EC2 Ubuntu Server</h1>
<p>I will take you through the process of setting up your first server on an Amazon
Elastic Compute Cloud (EC2) Ubuntu Server.</p>
<h2 id="sign-up-for-amazon-web-services-free-tier">Sign up for Amazon Web Services Free Tier</h2>
<ul>
<li>Tip: sign up with a new email if your account is older than a year</li>
</ul>
<h2 id="create-a-new-key-pair-or-upload-an-ssh-public-key">Create a New Key Pair or Upload an SSH Public Key</h2>
<ul>
<li>Visit <a href="https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#KeyPairs:" target="_blank">aws ssh key pairs</a></li>
<li>I have found it's easier to upload a public key that you've created on your own
machine. Visit <a href="https://help.github.com/articles/generating-ssh-keys" target="_blank">Github Help</a>
if you need help creating your own public/private key pair.</li>
</ul>
<h2 id="find-and-launch-an-ami">Find and launch an AMI</h2>
<ul>
<li>Google AWS Marketplace</li>
<li>Search for Ubuntu</li>
<li><a href="https://aws.amazon.com/marketplace/pp/B00JV9JBDS/ref=srh_res_product_title?ie=UTF8&sr=0-3&qid=1402960705314" target="_blank">I chose this 64 bit image</a>, you should too for this tutorial.</li>
<li>click the big yellow continue button</li>
<li>accept default options, except:<ul>
<li>make sure <strong>t1-micro</strong> is selected in EC2 Instance Type</li>
</ul>
</li>
<li>Launch with 1-Click</li>
</ul>
<h2 id="connect-to-your-ec2-machine-instance">Connect to your EC2 Machine Instance</h2>
<ul>
<li>Visit your <a href="https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#Instances:" target="_blank">EC2 Dashboard</a></li>
<li>instance state will be 'running' eventually</li>
<li>find Public IP column and note address</li>
<li><code>ssh ubuntu@PUBLIC-IP-ADDRESS</code><ul>
<li>make an A record on your domain in <a href="http://aws.amazon.com/route53/" target="_blank">Route 53</a>
for convenience</li>
</ul>
</li>
</ul>
<h2 id="install-prerequisites-and-common-packages">Install Prerequisites and Common Packages</h2>
<p>The <code>-y</code> option is helpful because apt won't for wait for you to press 'y', it
will just install the packages. Very helpful for when you're trying to script
this entire process.</p>
<pre><code>sudo apt-get update && sudo apt-get install -y build-essential g++ tmux
</code></pre><h2 id="install-node-build-from-source">Install Node, Build from Source</h2>
<pre><code>curl -O http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz
tar -xvzf node-v0.10.29.tar.gz
cd node-v0.10.29
./configure --prefix=/opt/node
make
sudo mkdir -p /opt/node
sudo chown -R ubuntu.ubuntu /opt/node
make install
</code></pre><p>Add node to your path in <code>~/.bashrc</code>:</p>
<p><code>echo "export PATH=/opt/node/bin:$PATH" >> ~/.bashrc</code></p>
<p>Then reload <code>.bashrc</code></p>
<p><code>source ~/.bashrc</code></p>
<p>Double check to see that node is in your path:</p>
<p><code>which node</code> => should be <code>/opt/node/bin/node</code></p>
<p>Now, we need to add node to root's path too. To do this, we will need to use the
<code>visudo</code> command to edit the secure path.</p>
<p><code>sudo visudo</code></p>
<p>edit your <code>Defaults secure_path=</code> line, around the thrird line, to look like:</p>
<p><code>Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/node/bin"</code></p>
<p>The key here is to put the path to node at the end of the secure path.</p>
<p>Go ahead and save the file.</p>
<h2 id="install-the-latest-mongodb">Install the Latest MongoDB</h2>
<p>Follow the directions here:
<a href="http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/" target="_blank">http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/</a></p>
<p>To summarize:</p>
<pre><code>sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install mongodb-org
</code></pre><h2 id="install-the-latest-redis">Install the Latest Redis</h2>
<p>Luckily, Chris Lea keeps an up-to-date ubuntu ppa available.</p>
<pre><code>sudo add-apt-repository ppa:chris-lea/redis-server
sudo apt-get update
sudo apt-get install redis-server -y
</code></pre><h2 id="install-the-latest-git">Install the Latest Git</h2>
<pre><code>sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git -y
</code></pre><h3 id="test-mongodb-is-running">Test MongoDB is running</h3>
<pre><code>mongo
show dbs
</code></pre><ul>
<li>ctrl-d to exit</li>
</ul>
<h3 id="test-redis-is-running">Test Redis is running</h3>
<ul>
<li><code>redis-cli ping</code> --> should see <code>PONG</code></li>
</ul>
<h2 id="a-neat-trick-to-find-the-external-ip">A Neat Trick to Find the External IP</h2>
<p>You can always find the External IP address of your server in the EC2 Dashboard,
but I frequently use this shortcut from the command line:</p>
<p><code>curl icanhazip.com</code></p>
<h2 id="bower-all-the-things">Bower ALL THE THINGS</h2>
<p>I mean, install bower and any other global npm packages you use frequently.</p>
<p><code>npm -g install bower grunt-cli</code></p>
<h2 id="clone-your-app-and-install-npm-and-bower-packages">Clone Your App and Install NPM and Bower Packages</h2>
<p>I'll use one of our example apps. </p>
<p>Make sure you're in the ubuntu home directory: <code>/home/ubuntu</code> </p>
<pre><code>cd
git clone https://github.com/codefellows/javascript-b15-notes.git notes
cd notes
npm install && bower install
</code></pre><h2 id="launch-the-server-on-port-80">Launch the server on Port 80</h2>
<p>To launch your app, and bind on any port under 1000, you need to use <code>sudo</code> to
escalate to root privelege.</p>
<pre><code>sudo -i
PORT=80 node server.js
</code></pre><p>visit the site <a href="http://YOUR-IP-HERE" target="_blank">http://YOUR-IP-HERE</a></p>
<p>This will do in a pinch, but it's not a professional setup. What happens if your
server reboots? You want something to re-start the server automatically.</p>
<h2 id="install-the-forever-npm-package">Install the Forever NPM Package</h2>
<p><code>npm -g install forever</code>. Forever is a simple CLI tool for ensuring that a given script runs continuously.</p>
<p>Create <code>/etc/init/notes.conf</code>. This is an <a href="http://en.wikipedia.org/wiki/Upstart" target="_blank">Ubuntu Upstart</a> script.</p>
<p>You can always use <code>nano</code> if you are <a href="http://vim-adventures.com" target="_blank">afraid of Vim…</a></p>
<p><code>/etc/init/notes.conf</code>:</p>
<pre><code>start on startup
stop on shutdown
expect fork
script
PATH=/opt/node/bin:$PATH
exec forever start /home/ubuntu/notes/server.js
end script
pre-stop script
PATH=/opt/node/bin:$PATH
exec forever stop /home/ubuntu/notes/server.js
end script
</code></pre><p>Then <code>sudo start notes</code> to start the app</p>
<p>You can use use <code>sudo status notes</code> to see the status of the service.</p>
</section>
</div>
</div>
</div>
<a href="../auth_auth/angular_jwt_basic.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Angular Client Auth"><i class="fa fa-angle-left"></i></a>
</div>
</div>
<script src="../gitbook/jsrepl/jsrepl.js" id="jsrepl-script"></script>
<script src="../gitbook/app.js"></script>
<script src="http://cdn.mathjax.org/mathjax/2.0-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script src="../gitbook/plugins/gitbook-plugin-mathjax/plugin.js"></script>
<script>
require(["gitbook"], function(gitbook) {
var config = {};
gitbook.start(config);
});
</script>
</body>
</html>