We've seen how to deploy our website
to a fully managed platform,
such as Vercel or Netlify.
Now I want to show you a quick example
of how we can also deploy it to our own servers.
In this case I'm going to set up the Nginx web server
on a Ubuntu machine running in Digital Ocean.
Now, this requires some knowledge
of Linux system administration,
so if it's not something you're familiar with,
feel free to skip this video,
or maybe watch it but just to get an idea.
Anyway, here I'm logged into
my Digital Ocean dashboard,
and I have already created a server,
or "droplet" as Digital Ocean calls it,
based on Ubuntu Linux 20.04.
This is the IP address for that server,
and I'm going to copy it
so that I can connect to the server using SSH.
And I can connect as the "root" user.
I'm now logged in,
and this machine so far only has
the base Ubuntu system,
as created by Digital Ocean.
What I'm going to do now
is install the "nginx" web server,
using "apt", that is the system package manager.
Now, "nginx" depends on some other packages,
so we need to confirm
that we want to install everything.
Ok, this should have installed
the "nginx" web server.
So we should be able to open
this IP address in the web browser,
and we can see the default page served by "nginx".
This shows that the web server is running correctly.
But of course we want to replace this page
with our own website.
To do that we need to upload our website
to this IP address.
For the upload I'm going to use an FTP client
called "Cyberduck".
Cyberduck is only available for macOS,
but you can use any FTP client you like.
Anyway, I'm going to open a new connection
setting "SFTP" as the protocol.
Then I need to paste the IP address for the "Server",
and enter "root" as the "Username".
I don't need a password because
I'm using an SSH key for authentication,
and it's the same I already used for SSH.
So let's "Connect".
We need to accept the server fingerprint.
And we can now browse the server file system.
Now, Nginx keeps its websites under "/var/www",
and the "html" folder contains the default website.
Here there's this "index.nginx-debian.html" file
that must be the page we saw in the browser.
Let's try deleting it,
and if we go back to that page,
and reload it.
You can see that it's no longer available.
Now we want to upload our website,
so let's open the "dist" folder
that we created in the previous video,
by using the "next export" command.
We want to take all the files
that are inside the "dist" folder,
and drag them onto the "html" folder on the server.
Let me "Always" accept the server fingerprint,
otherwise it'll keep asking every time.
But this has now uploaded all the files
for our static website onto the server.
So at this point, if we go back to the browser
and reload the page,
we can see our Blog running on our own Nginx server.
And it all seems to be working perfectly fine.
Note that as it is the website is using plain HTTP,
in fact Chrome shows a "Not Secure" warning
in the address bar.
Setting up HTTPs would require
some additional steps,
but this should give you an idea of
what's involved in running your own web server.
I used Digital Ocean for this example,
but you could use any other cloud provider of course,
like Amazon EC2 or Google Cloud.
The one thing I like about Digital Ocean
is that they have good tutorials,
and in fact you'll find a link to the page
on how to up Nginx in the lecture resources.