Skip to content

Commit 6721f27

Browse files
README: change order of operations so that user management and setup takes place where it should: before everything else.
1 parent fe398ed commit 6721f27

File tree

1 file changed

+35
-29
lines changed

1 file changed

+35
-29
lines changed

README.md

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ Hand out a public IP which can be hit with a curl request.
4545
8. Deploy on AWS Linux Ubuntu EC2 VM instance.
4646
<br><br> This will involve setting up the virtual Ubuntu machine (14.04) using the AWS Console as well as selecting appropriate security groups. This will also involve setting up a new or existing key pair for secure SSH. Server user administration should not involve logging in with a password; instead, allow users access via their keys, and remove their access by removing their keys. Once an AWS EC2 Ubuntu instance is up and running, you can install desired software using appropriate package management tools, as follows.
4747

48-
Getting started on AWS EC2 Ubuntu will involve downloading your private key keyname.pem, putting it in:
48+
<strong>Logging in</strong>
49+
50+
Getting started on AWS EC2 Ubuntu will involve first logging in using keys. Start by downloading your private key keyname.pem, putting it in:
4951
```
5052
~/.ssh/keyname.pem
5153
```
@@ -61,34 +63,6 @@ Scp a file to user's home ~/. Note that we aren't using rsync at this time.
6163
```
6264
$ scp -i /path/to/keyname.pem /path/file.txt user@AWSpublicDNS:~
6365
```
64-
User management follows in "step 3" of AWS process documented here. You don't want users to have to have your private key to login, of course. You'll also note that we have a "deploy user" for purposes of this simple Vertical Slice full stack app, but generally <strong>Jenkins</strong> or a similar continuous integration solution would deploy, not a user. <strong> You really don't want to setup your server as the "ubuntu" user, so strongly consider skipping ahead here to the user management stuff in step 3.</strong>
65-
66-
<strong>Once you're set up properly with users, and have AWS access both as a non-ubuntu-username sudoer AND as a non-sudoer 'deploy' user that's in the same group as www-data:</strong>
67-
68-
<strong>First you have to install Node: </strong> <br>
69-
I chose to install Node on AWS using nvm instead of using Debian's apt-get package manager to install Node. That's because nvm helps you manage specific versions of Node on a per-project basis. As with all npm-related projects, the point of a per-project package manager includes project-directory installations of software packages/versions *instead of global installs.*
70-
71-
$ nvm script
72-
// To verify installed version:
73-
$ command -v nvm
74-
// Install the version you want:
75-
$ nvm install 4.2.3
76-
// To specify version in nvmrc file for THIS project directory (remember that one of the points of using npm is to manage packages PER project, and that's why global installs are something to watch out for and often avoid:) From project root dir:
77-
$ echo "4.2.3" > .nvmrc
78-
// Now, to USE that Node version:
79-
$ nvm use
80-
81-
<strong>Second, you'll need to install a web server. I chose nginx instead of Apache or other options, and I installed it using Debian (Ubuntu) Linux's distribution's package manager tools apt-get. </strong> The point here is that we are managing our own installations rather than always using installers providers give us. It's always best to spin things up by hand so you learn the underlying logic/tech. MAGIC BAD.
82-
83-
$ apt-get install nginx // or similar
84-
// you can start and stop nginx signals as such:
85-
$ sudo service yourappdirectory start
86-
$ sudo nginx -s reload
87-
88-
Note that with the above, yourappdirectory will read nodeapp for us in the future.
89-
90-
<strong>Third, you have to set up the proper users, groups, and permissions. </strong>
91-
Set and manage shell users and permissions on EC2 instance. Your deploy user cannot be a sudo-er. You want to restrict permissions and be conservative.
9266

9367
Recall permissions are in binary/hex as such. Here is an example of our users group being able to read, write and execute, and everyone else can just read:
9468
```
@@ -236,6 +210,38 @@ $ id gobbluth
236210

237211
<strong>After you add a user and group, set a password for that user, and add the user to the appropriate group, you'll need to copy the public key for that user to the authorized keys directory for that user. </strong> *Check back with the numbered list items for user management above to ensure you went through all the steps. If you want another user to assume deploy, you'll have to copy that user's public key into the authorized_keys file for that user. Note that we normally wouldn't have a user deploying code, we'd use Jenkins or similar CI.*
238212

213+
<strong>Once you're set up properly with users, install git and curl:</strong>
214+
```
215+
$ sudo apt-get install curl git
216+
```
217+
218+
<strong>Now we begin standing up the server:</strong>
219+
220+
<strong>First you have to install Node: </strong> <br>
221+
I chose to install Node on AWS using nvm instead of using Debian's apt-get package manager to install Node. That's because nvm helps you manage specific versions of Node on a per-project basis. As with all npm-related projects, the point of a per-project package manager includes project-directory installations of software packages/versions *instead of global installs.*
222+
223+
$ nvm script
224+
// To verify installed version:
225+
$ command -v nvm
226+
// Install the version you want:
227+
$ nvm install 4.2.3
228+
// To specify version in nvmrc file for THIS project directory (remember that one of the points of using npm is to manage packages PER project, and that's why global installs are something to watch out for and often avoid:) From project root dir:
229+
$ echo "4.2.3" > .nvmrc
230+
// Now, to USE that Node version:
231+
$ nvm use
232+
233+
<strong>Second, you'll need to install a web server. I chose nginx instead of Apache or other options, and I installed it using Debian (Ubuntu) Linux's distribution's package manager tools apt-get. </strong> The point here is that we are managing our own installations rather than always using installers providers give us. It's always best to spin things up by hand so you learn the underlying logic/tech. MAGIC BAD.
234+
235+
$ apt-get install nginx // or similar
236+
// you can start and stop nginx signals as such:
237+
$ sudo service yourappdirectory start
238+
$ sudo nginx -s reload
239+
240+
Note that with the above, yourappdirectory will read nodeapp for us in the future.
241+
242+
<strong>Third, you have to set up the proper users, groups, and permissions. </strong>
243+
Set and manage shell users and permissions on EC2 instance. Your deploy user cannot be a sudo-er. You want to restrict permissions and be conservative.
244+
239245
<strong>Fourth, you have to spin up a service by hand on the AWS EC2 Ubuntu instance using upstart daemon, make it executable, and set the proper Linux run levels. Of course, a sudoer must complete all of these tasks, not your deploy user. You're replacing the start-at-boot init.d daemon with one of your own!</strong>
240246

241247
Create the conf file: Where nodeapp is the name of your app's directory:

0 commit comments

Comments
 (0)