1
00:00:00,079 --> 00:00:01,256
- [Voiceover] Hi and welcome back.

2
00:00:01,256 --> 00:00:05,239
In this video we're going to
be setting up DigitalOcean.

3
00:00:05,239 --> 00:00:08,827
DigitalOcean is a provider of servers

4
00:00:08,827 --> 00:00:11,255
which means we can rent a server from them

5
00:00:11,255 --> 00:00:14,461
for a small amount of money each month.

6
00:00:14,461 --> 00:00:17,781
What that means, and the way
it's different from Heroku

7
00:00:17,781 --> 00:00:20,564
is that in DigitalOcean we get access

8
00:00:20,564 --> 00:00:22,395
to the computer itself

9
00:00:22,395 --> 00:00:24,836
that is running our software.

10
00:00:24,836 --> 00:00:26,456
That means we can do things like

11
00:00:26,456 --> 00:00:28,247
change the users,

12
00:00:28,247 --> 00:00:30,611
add more programmes to run

13
00:00:30,611 --> 00:00:32,689
in the server simultaneously,

14
00:00:32,689 --> 00:00:35,724
as opposed to just our application.

15
00:00:35,724 --> 00:00:38,595
We can change security perimeters.

16
00:00:38,595 --> 00:00:41,325
We can potentially even
deploy our application

17
00:00:41,325 --> 00:00:43,660
to many servers and connect them together.

18
00:00:43,660 --> 00:00:46,011
Essentially we can do anything we want,

19
00:00:46,011 --> 00:00:48,990
because when we rent through DigitalOcean

20
00:00:48,990 --> 00:00:53,002
we are going to own the server
in which the app is running.

21
00:00:53,002 --> 00:00:55,876
However, when we deploy on Heroku,

22
00:00:55,876 --> 00:00:58,316
Heroku servers run our app,

23
00:00:58,316 --> 00:01:02,250
but we don't get access
to the servers themselves.

24
00:01:02,250 --> 00:01:06,220
So if you want to deploy your application,

25
00:01:06,220 --> 00:01:08,128
and you want your application to scale,

26
00:01:08,128 --> 00:01:10,404
and you want to keep costs down,

27
00:01:10,404 --> 00:01:14,201
but you are willing to do a bit more work,

28
00:01:14,201 --> 00:01:17,888
DigitalOcean maybe the tool for you.

29
00:01:17,888 --> 00:01:19,261
There is a bit more work involved

30
00:01:19,261 --> 00:01:20,882
when deploying with DigitalOcean

31
00:01:20,882 --> 00:01:24,521
because we have to set
up each of the servers.

32
00:01:24,521 --> 00:01:26,014
In Heroku we just press a button

33
00:01:26,014 --> 00:01:27,349
and the app gets deployed.

34
00:01:27,349 --> 00:01:29,700
Here we'll have to instal the database

35
00:01:29,700 --> 00:01:33,589
and instal the application
into the server and run it.

36
00:01:33,589 --> 00:01:35,301
But it shouldn't take too long.

37
00:01:35,301 --> 00:01:36,758
And once you know how to do it,

38
00:01:36,758 --> 00:01:39,425
it'll be a fairly quick process.

39
00:01:40,851 --> 00:01:44,024
Now the link that you are
seeing on your screen right now

40
00:01:44,024 --> 00:01:47,358
is a link that you can use
to sign up to DigitalOcean,

41
00:01:47,358 --> 00:01:51,591
and that will give you two
free months off of server rent.

42
00:01:51,591 --> 00:01:54,243
Which means you'll be able to trial out

43
00:01:54,243 --> 00:01:56,518
what you see in this section,

44
00:01:56,518 --> 00:01:58,362
and you'll be able to
deploy your applications

45
00:01:58,362 --> 00:02:00,870
to DigitalOcean and give them a go.

46
00:02:00,870 --> 00:02:03,622
Two months is not a very long time,

47
00:02:03,622 --> 00:02:05,818
but it's better than nothing.

48
00:02:05,818 --> 00:02:09,471
So hopefully you find use for that.

49
00:02:09,471 --> 00:02:10,921
Okay, so what we're gonna do is

50
00:02:10,921 --> 00:02:12,634
we're going to go to that link,

51
00:02:12,634 --> 00:02:15,738
and that'll bring you to the sign up page.

52
00:02:15,738 --> 00:02:16,633
And here all you have to do

53
00:02:16,633 --> 00:02:19,626
is put in your email
address, and a password.

54
00:02:19,626 --> 00:02:20,546
And once you've done that

55
00:02:20,546 --> 00:02:24,728
you'll be going straight into
the DigitalOcean console.

56
00:02:24,728 --> 00:02:27,895
Let's have a look at what is in there.

57
00:02:29,756 --> 00:02:32,992
Here you see that I've
got a number of droplets.

58
00:02:32,992 --> 00:02:37,188
In DigitalOcean, droplet are
the servers that you own.

59
00:02:37,188 --> 00:02:40,115
As you can see I've got four
servers running right now.

60
00:02:40,115 --> 00:02:42,593
For a total of $20 per month.

61
00:02:42,593 --> 00:02:44,497
As you can see it costs a bit of money,

62
00:02:44,497 --> 00:02:46,021
but it's not too much.

63
00:02:46,021 --> 00:02:48,472
It's not too expensive.

64
00:02:48,472 --> 00:02:49,930
Each of these servers can cope

65
00:02:49,930 --> 00:02:51,682
with quite a lot of load,

66
00:02:51,682 --> 00:02:54,349
because they are very fast.

67
00:02:55,242 --> 00:02:57,173
And they've got a solid state drive.

68
00:02:57,173 --> 00:02:59,194
They've got a reasonable amount of RAM.

69
00:02:59,194 --> 00:03:01,929
Certainly for a REST API.

70
00:03:01,929 --> 00:03:04,779
So they can do a lot of stuff.

71
00:03:04,779 --> 00:03:06,004
I've got these servers running

72
00:03:06,004 --> 00:03:08,373
because I like having my
things running separately.

73
00:03:08,373 --> 00:03:10,488
But I could potentially be running

74
00:03:10,488 --> 00:03:11,966
the things that are running
on these four servers

75
00:03:11,966 --> 00:03:15,966
on just a single server,
and that would be okay.

76
00:03:16,970 --> 00:03:20,778
So whenever we want to
start creating a new server

77
00:03:20,778 --> 00:03:24,945
we just go ahead and click
on the create droplet button.

78
00:03:26,791 --> 00:03:29,422
And we're gonna be setting
up a droplet, a new server,

79
00:03:29,422 --> 00:03:32,339
for the deployments in this course.

80
00:03:33,246 --> 00:03:36,671
What we wanna do is, first
of all, choose an image.

81
00:03:36,671 --> 00:03:40,838
This is what operating system
the droplet is going to run.

82
00:03:42,211 --> 00:03:46,378
In our case we're going
to choose Ubuntu 16.04.

83
00:03:47,742 --> 00:03:52,181
If you see Ubuntu 16.04.2
for example then that's okay.

84
00:03:52,181 --> 00:03:55,366
Just stick with 16.04.

85
00:03:55,366 --> 00:03:59,219
And I know that there's
a newer version 16.10.

86
00:03:59,219 --> 00:04:00,792
And by the time you're watching this

87
00:04:00,792 --> 00:04:02,696
you may even see 17.

88
00:04:02,696 --> 00:04:05,404
However, 16.04

89
00:04:05,404 --> 00:04:08,005
is an LTS distribution of Ubuntu.

90
00:04:08,005 --> 00:04:10,063
That means long term support.

91
00:04:10,063 --> 00:04:12,539
Which means that this distribution
is going to be supported

92
00:04:12,539 --> 00:04:16,539
for a lot longer time
than for example 17 might.

93
00:04:18,112 --> 00:04:20,298
So stick with Ubuntu 16.04,

94
00:04:20,298 --> 00:04:23,502
and when the time comes I'll
update the course accordingly

95
00:04:23,502 --> 00:04:27,419
to use the next long term
support distribution.

96
00:04:28,305 --> 00:04:31,933
So whenever you're watching
this video stick to 16.04.

97
00:04:31,933 --> 00:04:34,908
For a size we're going to
stick with the cheapest one

98
00:04:34,908 --> 00:04:36,530
for testing our deployments.

99
00:04:36,530 --> 00:04:37,892
This is $5 a month,

100
00:04:37,892 --> 00:04:39,978
and here you may have to give your

101
00:04:39,978 --> 00:04:42,787
debit card details or credit card details,

102
00:04:42,787 --> 00:04:46,513
or use a $10 sign up bonus

103
00:04:46,513 --> 00:04:49,096
if you use the link I provided.

104
00:04:50,104 --> 00:04:51,187
So choose the cheapest one,

105
00:04:51,187 --> 00:04:53,730
unless of course you have
something else you wanna run,

106
00:04:53,730 --> 00:04:57,450
and then you maybe wanna
use a more expensive one.

107
00:04:57,450 --> 00:04:59,609
Then we'll get to this
section to add block storage,

108
00:04:59,609 --> 00:05:01,146
and we're just gonna ignore that.

109
00:05:01,146 --> 00:05:02,064
We don't want block storage

110
00:05:02,064 --> 00:05:06,064
because our application does not need it.

111
00:05:06,064 --> 00:05:09,230
And finally we choose a datacenter region.

112
00:05:09,230 --> 00:05:12,742
DigitalOcean is a fairly
large server provider

113
00:05:12,742 --> 00:05:16,550
so it has servers available
in many different places.

114
00:05:16,550 --> 00:05:18,295
The difference between
each of these regions

115
00:05:18,295 --> 00:05:21,998
is how far away the region is

116
00:05:21,998 --> 00:05:23,398
from your users.

117
00:05:23,398 --> 00:05:25,768
For example, I'm in the UK.

118
00:05:25,768 --> 00:05:29,190
If all of my users, all
of my REST API users,

119
00:05:29,190 --> 00:05:33,261
are in the UK as well, I
may wanna go for London.

120
00:05:33,261 --> 00:05:35,527
That is because connecting to London

121
00:05:35,527 --> 00:05:38,282
will be a lot faster than
connecting to New York,

122
00:05:38,282 --> 00:05:39,670
just because if you connect to New York

123
00:05:39,670 --> 00:05:41,395
you have to go through the ocean

124
00:05:41,395 --> 00:05:44,447
in the underground lines,

125
00:05:44,447 --> 00:05:46,254
and that takes a few milliseconds,

126
00:05:46,254 --> 00:05:49,991
whereas connecting to
London will be a lot faster.

127
00:05:49,991 --> 00:05:53,238
The Amsterdam datacenters
are particularly good.

128
00:05:53,238 --> 00:05:54,740
So you may wanna go for that,

129
00:05:54,740 --> 00:05:56,352
and that's what I normally go for.

130
00:05:56,352 --> 00:05:59,506
It's very good for European customers.

131
00:05:59,506 --> 00:06:01,194
Naturally if you are in the US

132
00:06:01,194 --> 00:06:03,127
you may wanna go for New
York or San Francisco

133
00:06:03,127 --> 00:06:05,456
depending on whether you're
in the east or the west.

134
00:06:05,456 --> 00:06:07,480
If you're in Canada go for Toronto.

135
00:06:07,480 --> 00:06:10,813
And so on for the other regions as well.

136
00:06:12,472 --> 00:06:15,216
Then we get to selecting
additional options.

137
00:06:15,216 --> 00:06:17,493
We've got a bunch of things here.

138
00:06:17,493 --> 00:06:20,842
Private networking, which
allows two of our droplets,

139
00:06:20,842 --> 00:06:23,733
which we don't have two
yet, we've only got one.

140
00:06:23,733 --> 00:06:26,144
It allows two of our droplets
to connect to each other

141
00:06:26,144 --> 00:06:28,281
without going through the internet.

142
00:06:28,281 --> 00:06:31,207
It means their connection goes faster,

143
00:06:31,207 --> 00:06:32,476
but we don't need that just now.

144
00:06:32,476 --> 00:06:35,949
For example, it might
allow your REST API droplet

145
00:06:35,949 --> 00:06:38,411
to connect to a database droplet

146
00:06:38,411 --> 00:06:39,696
if that's what we wanted to do.

147
00:06:39,696 --> 00:06:42,369
In this section we're going
to be installing the REST API

148
00:06:42,369 --> 00:06:46,484
and the database on the same
droplet, so we don't need this.

149
00:06:46,484 --> 00:06:47,463
Backups.

150
00:06:47,463 --> 00:06:50,391
It allows for your
droplet to keep a backup,

151
00:06:50,391 --> 00:06:52,537
and that makes it slightly more expensive.

152
00:06:52,537 --> 00:06:55,256
It adds 20% of the monthly cost.

153
00:06:55,256 --> 00:06:57,058
But of course if you wanna keep the data

154
00:06:57,058 --> 00:06:59,671
and you wanna make sure
your data is not lost,

155
00:06:59,671 --> 00:07:02,075
then you may wanna check that.

156
00:07:02,075 --> 00:07:03,424
For now we're gonna leave it unchecked

157
00:07:03,424 --> 00:07:05,440
because this is just a trial

158
00:07:05,440 --> 00:07:09,155
for learning how to deploy so
we don't need that in here.

159
00:07:09,155 --> 00:07:10,238
IPv6.

160
00:07:11,453 --> 00:07:14,113
Right now all droplets run with IPv4

161
00:07:14,113 --> 00:07:16,830
which is a pretty old version
of the internet protocol.

162
00:07:16,830 --> 00:07:18,118
The IP.

163
00:07:18,118 --> 00:07:20,606
But IPv6, the newer version,

164
00:07:20,606 --> 00:07:23,231
is rolling out and is
becoming more popular.

165
00:07:23,231 --> 00:07:25,526
And if you need that, which
we don't in this section,

166
00:07:25,526 --> 00:07:26,800
then you may wanna check that.

167
00:07:26,800 --> 00:07:29,316
If you don't know what that
is just leave it unchecked.

168
00:07:29,316 --> 00:07:31,184
And finally user data which is some

169
00:07:31,184 --> 00:07:33,926
DigitalOcean specific
configuration perimeters.

170
00:07:33,926 --> 00:07:37,416
We're gonna leave that unchecked.

171
00:07:37,416 --> 00:07:39,178
Then we look at SSH keys

172
00:07:39,178 --> 00:07:40,777
which we know what they are now.

173
00:07:40,777 --> 00:07:43,955
You can add your SSH key if you want.

174
00:07:43,955 --> 00:07:45,003
And what that'll do is

175
00:07:45,003 --> 00:07:48,736
that won't generate a
password for your account.

176
00:07:48,736 --> 00:07:52,106
Instead, you will have to
connect with the computer

177
00:07:52,106 --> 00:07:54,697
that owns this SSH key.

178
00:07:54,697 --> 00:07:57,780
If you're not sure, I
would leave it unchecked,

179
00:07:57,780 --> 00:08:00,215
or just don't add an SSH key.

180
00:08:00,215 --> 00:08:01,816
That will generate a password

181
00:08:01,816 --> 00:08:03,345
and you'll be able to
connect to your account

182
00:08:03,345 --> 00:08:06,420
from anywhere no matter
what computer you're using.

183
00:08:06,420 --> 00:08:07,806
If you check the SSH key,

184
00:08:07,806 --> 00:08:10,386
you'll only be able to
connect with the computer

185
00:08:10,386 --> 00:08:12,974
that owns the SSH key.

186
00:08:12,974 --> 00:08:14,520
In my case this is my laptop.

187
00:08:14,520 --> 00:08:15,753
If I had two laptops,

188
00:08:15,753 --> 00:08:17,766
my second laptop wouldn't
be able to connect,

189
00:08:17,766 --> 00:08:20,849
because it wouldn't own this SSH key.

190
00:08:21,976 --> 00:08:24,256
And finally we're gonna create.

191
00:08:24,256 --> 00:08:26,302
So we're gonna select how
many droplets we want.

192
00:08:26,302 --> 00:08:28,092
In my case I'm gonna select one droplet,

193
00:08:28,092 --> 00:08:29,658
and then we're gonna choose a hostname.

194
00:08:29,658 --> 00:08:31,082
And here I would recommend something

195
00:08:31,082 --> 00:08:32,678
that makes sense to you.

196
00:08:32,678 --> 00:08:35,069
For example, you may call it

197
00:08:35,069 --> 00:08:39,311
REST API course and trial.

198
00:08:39,311 --> 00:08:41,218
Or something like that.

199
00:08:41,218 --> 00:08:43,617
Okay, finally you may
add a tag if you want,

200
00:08:43,617 --> 00:08:46,867
and I'm gonna add the tag course there.

201
00:08:49,150 --> 00:08:51,983
And then let's press create.

202
00:08:51,983 --> 00:08:54,590
Now these droplets take
a few seconds to create,

203
00:08:54,590 --> 00:08:56,308
but as you can see they're very quick.

204
00:08:56,308 --> 00:08:58,264
It should take less than 60 seconds

205
00:08:58,264 --> 00:09:00,248
to create your new server,

206
00:09:00,248 --> 00:09:03,331
and then it will be ready to be used.

207
00:09:04,218 --> 00:09:06,260
Okay, that's all server ready.

208
00:09:06,260 --> 00:09:09,752
Now we can go to our email address

209
00:09:09,752 --> 00:09:11,142
that is registered with this account,

210
00:09:11,142 --> 00:09:13,709
and you should receive an email

211
00:09:13,709 --> 00:09:17,342
telling you the password for the account.

212
00:09:17,342 --> 00:09:19,509
Or you can just go to more

213
00:09:20,375 --> 00:09:22,520
and press on access console.

214
00:09:22,520 --> 00:09:24,257
And what this will do

215
00:09:24,257 --> 00:09:27,840
is this will bring you
to the console here.

216
00:09:30,147 --> 00:09:32,919
The login is root,

217
00:09:32,919 --> 00:09:34,710
and the password is once again

218
00:09:34,710 --> 00:09:36,690
what you've got on your email.

219
00:09:36,690 --> 00:09:38,623
So I'm going to go and check the email

220
00:09:38,623 --> 00:09:40,115
and retrieve the password from it,

221
00:09:40,115 --> 00:09:43,275
and then go and put it back in here.

222
00:09:43,275 --> 00:09:46,859
Okay, we left it up here
when we put in our password

223
00:09:46,859 --> 00:09:49,010
that you should find on your email.

224
00:09:49,010 --> 00:09:50,738
And then we have to change the password.

225
00:09:50,738 --> 00:09:52,377
That's a requirement to make sure to use

226
00:09:52,377 --> 00:09:54,943
a reasonably secure password.

227
00:09:54,943 --> 00:09:57,392
And as you can see here I
put the password in again,

228
00:09:57,392 --> 00:10:00,752
and then I typed in my new
password which have setup.

229
00:10:00,752 --> 00:10:02,396
And after you type in your new password

230
00:10:02,396 --> 00:10:05,250
you'll be received with this screen here

231
00:10:05,250 --> 00:10:09,196
which is the Ubuntu load up screen.

232
00:10:09,196 --> 00:10:10,929
And that means once you've done that

233
00:10:10,929 --> 00:10:13,936
that you are ready to
start using your server.

234
00:10:13,936 --> 00:10:15,490
We are now connected,

235
00:10:15,490 --> 00:10:18,573
and we are connected as the root user

236
00:10:19,414 --> 00:10:23,645
in the REST API course trial server.

237
00:10:23,645 --> 00:10:27,436
So this means we're the root user

238
00:10:27,436 --> 00:10:30,906
at the REST API course trial server.

239
00:10:30,906 --> 00:10:33,220
And now in this blinking cursor

240
00:10:33,220 --> 00:10:36,003
we can start typing our commands.

241
00:10:36,003 --> 00:10:37,953
This is running Ubuntu

242
00:10:37,953 --> 00:10:40,654
which is a Unix server.

243
00:10:40,654 --> 00:10:44,639
Just like Mac, CentOS, Arch,

244
00:10:44,639 --> 00:10:46,333
and many others are all Unix.

245
00:10:46,333 --> 00:10:49,767
So we're gonna be typing
our commands in here.

246
00:10:49,767 --> 00:10:50,739
And we're going to be installing

247
00:10:50,739 --> 00:10:54,259
PostgreSQL, Nginx, and our application.

248
00:10:54,259 --> 00:10:56,534
We're gonna go through
exactly where all those are

249
00:10:56,534 --> 00:10:58,569
in the next few videos.

250
00:10:58,569 --> 00:11:00,753
If you've not managed
to get to this screen

251
00:11:00,753 --> 00:11:04,939
where you are logged
in as root in your box,

252
00:11:04,939 --> 00:11:07,987
in your droplet, then please stop here.

253
00:11:09,485 --> 00:11:12,068
Do not continue without

254
00:11:12,956 --> 00:11:15,454
having your droplet setup.

255
00:11:15,454 --> 00:11:18,357
If you don't want to pay

256
00:11:18,357 --> 00:11:21,004
or to sign up to
DigitalOcean at this point,

257
00:11:21,004 --> 00:11:24,424
I would recommend that you
don't follow this section at all

258
00:11:24,424 --> 00:11:26,831
until you are ready to
deploy to DigitalOcean.

259
00:11:26,831 --> 00:11:28,754
Just because we're gonna be going through

260
00:11:28,754 --> 00:11:32,022
a bunch of commands, and if
you don't do these commands

261
00:11:32,022 --> 00:11:34,105
alongside the videos, you're
just gonna forget them,

262
00:11:34,105 --> 00:11:35,905
and it's gonna be a waste of time.

263
00:11:35,905 --> 00:11:38,272
So if you don't want to
deploy to DigitalOcean

264
00:11:38,272 --> 00:11:39,521
don't follow this section,

265
00:11:39,521 --> 00:11:41,997
because it doesn't make
sense for you to do that.

266
00:11:41,997 --> 00:11:44,230
And you can follow this
section in six months,

267
00:11:44,230 --> 00:11:47,722
twelve months time, when you
want to deploy to DigitalOcean.

268
00:11:47,722 --> 00:11:48,856
If you want to.

269
00:11:48,856 --> 00:11:51,044
If you don't want to you
can stick with Heroku

270
00:11:51,044 --> 00:11:53,490
for a very very long time.

271
00:11:53,490 --> 00:11:55,469
Okay, so that's everything for this video,

272
00:11:55,469 --> 00:11:57,656
and I'll see you on the very next one.

