Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 103 lines (62 sloc) 3.287 kB
a31ba57 @rsms initial import
authored
1 # Setup and installation
2
3 First of all, make a clone or [fork of this repository](https://github.com/rsms/ec2-webapp/fork) and replace all occurrences of `myapp` with a name of your choice. Same goes for `myapp` in this guide.
4
5 ## Launch an EC2 instance
6
7 [Start a "micro" Amazon EC2 instance](https://console.aws.amazon.com/ec2/home) and use one of the following AMIs, depending on where you chose to launch it:
8
9 - US west: `ami-ad7e2ee8`
10 - US east: `ami-ccf405a5`
11 - EU west: `ami-fb9ca98f`
12 - Asia Pacific (Singapore): `ami-0c423c5e`
13
14 > These AMIs where taken from <http://uec-images.ubuntu.com/releases/10.10/release/>
15
16 Go with the defaults in the "wizard" presented. Chose to create a new key pair when asked and **be sure to make a secure backup of the private key** that you will download. A good place to put your private key is in `~/.ssh/myapp.pem` and then `chmod 0600 ~/.ssh/myapp.pem` so no one else can read it but you.
17
18 When the instance is green and "started", log in to the machine:
19
20 ssh -i ~/.ssh/myapp.pem ubuntu@XXX.amazonaws.com
21
22 *Note: Replace `XXX.amazonaws.com` with the hostname or address of your instance*
23
24
25 ## Install software
26
27 sudo apt-get update
28 sudo apt-get install nginx git-core daemon
29 sudo chown -R www-data:www-data /var/www
30
31 Node.js:
32
33 sudo apt-get install build-essential libssl-dev
34 cd
35 mkdir src
36 git clone https://github.com/joyent/node.git src/node
37 cd src/node
38 # Optionally: git checkout v0.4.3
39 ./configure
40 JOBS=2 make
41 sudo make install
42
43 NPM:
44
45 sudo echo && curl http://npmjs.org/install.sh | sudo sh
46 sudo npm install connect connect_json move
47
48
49 ## Checkout your source
50
51 sudo mkdir /var/myapp
52 sudo chown www-data:www-data /var/myapp
53
54 If your git repository is public (i.e. viewable by anyone):
55
56 sudo -Hu www-data git clone https://github.com/you/myapp.git /var/myapp
57
58 If your git repository is private:
59
60 sudo -Hu www-data ssh-keygen -t rsa # chose "no passphrase"
61 sudo cat /var/www/.ssh/id_rsa.pub
62 # Add the key as a "deploy key" at https://github.com/you/myapp/admin
63 sudo -Hu www-data git clone git@github.com:you/myapp.git /var/myapp
64
65
66 ## Configure & start your services
67
68 Your Node.js web server:
69
70 sudo ln -s /var/myapp/init.d/myapp-httpd /etc/init.d/
71 sudo update-rc.d myapp-httpd defaults
72 sudo invoke-rc.d myapp-httpd start
73
74 Optional `myapp-processor`:
75
76 sudo ln -s /var/myapp/init.d/myapp-processor /etc/init.d/
77 sudo update-rc.d myapp-processor defaults
78 sudo invoke-rc.d myapp-processor start
79
80
81 ## Configure Nginx
82
83 There are three different kinds of setups to chose from:
84
85 1. `myapp-http` -- HTTP only
86 2. `myapp-https` -- HTTPS with HTTP redirecting to HTTPS
87 3. `myapp-https-http` -- HTTPS and HTTP
88
89 If you are using HTTPS, make sure you have added your SSL certificate and key at `/var/myapp/ssl/ssl.crt` and `/var/myapp/ssl/ssl.key`.
90
91 Replace `myapp-https` below with the configuration of your choice:
92
93 sudo ln -sf /var/myapp/etc/nginx/sites-available/myapp-https \
94 /etc/nginx/sites-enabled/default
95 sudo invoke-rc.d nginx restart
96
97
98 ## Done
99
100 Your web app should now be operational.
101
9ac1d5b @rsms readme links
authored
102 If everything works, continue by reading [WORKFLOW.md](https://github.com/rsms/ec2-webapp/blob/master/WORKFLOW.md#readme)
Something went wrong with that request. Please try again.