Install Nginx and Node.js on a AWS EC2 Server

Sam Julien
InstructorSam Julien
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 4 years ago

Ghost has two hard dependencies which need to be installed before it can run. Those are Nginx and Node.js.

We will start by installing Nginx and set Nginx up to control the traffic coming into the EC2 server. After this, we'll install NVM using the raw install script that they provide on GitHub. With NVM installed we can then install the latest version of Node.js

Instructor: [0:00] We are ready to install a couple of prerequisites for Ghost onto our EC2 instance. The first one we're going to install is called NGINX. NGINX is a reverse proxy.

[0:13] Basically, what this means is that it's going to take any connections that come to our server trying to hit port 80, which is the standard port for basic websites, and it's going to route it over to the port that Ghost is running on. Let's do that first.

[0:27] We're going to hop over to our terminal. I'm already logged into our EC2 instance using our SSH private key, and I've already switched over to the Ghost admin user. You can do that, in case you forget, with su- and then ghost admin, and it'll prompt you for the password.

[0:47] I'm already logged in, though, so I'm going to go ahead and, run sudo apt-get install nginx, and let that run. It only takes a second. You do have to confirm. Let me clear that out.

[1:02] Then, we need to allow Nginx to control that traffic. We need to setup our firewall in our Ubuntu server to allow that. Luckily, there's one command that we need. It's, sudo ufw, that stands for uncomplicated firewall. It has a number of different settings. We're going to say allow 'Nginx Full'. This is a preset that will allow full privileges for Nginx.

[1:35] We'll link to some resources that you can read more about this, sudo ufw allow 'Nginx Full'. We'll go ahead and hit Enter. You can see this, Rules updated result. We've got one of our prerequisites done. The next prerequisite we're going to want to install is NVM, the Node Version Manager. Let's hop back over to the browser.

[1:56] I've got the NMV repository open here. What we want to do is scroll down and click on this Install an update script. We're going to use the wget. It doesn't matter which one you use. We're going to use the wget script. We're going to copy that over. Let's hop back over to our server in the terminal and paste that in.

[2:19] What we're doing here is we're going and getting the Rawk install script and we're typing it into Bash. We're going to go ahead and hit Enter. Now that's done. Now, what we need to do is refresh our session here with our Ghost admin account. What we need to do is, let's go ahead and clear this out, so you can see better, we're going to hit exit.

[2:42] That's going to return us back to our root user, our BluTube user. We need to switch back into our Ghost admin account, so su-ghost-admin. It will prompt you for the passwords. Type that in. Now, we're back up and running.

[2:58] We can check that this was correctly installed. We can say, command -v nvm, and it will echo that back out to us. Command -v will echo out how the shell will interpret a command that you're giving it. We can see here that it's going to call the NVM command when we pass it NVM.

[3:18] It's just a good way to check that something exists. Let's also install the latest LTS version of node. We can say, nvm install, and then parse the flag of LTS. We're going to say, --lts.

[3:33] That's going to tell NVM to install the latest version. At the time of this recording, it's version 14.15.5. That's also going to alias it to default.

[3:45] Great. If we do, node -v, which is the version, we're going to see 14.15.5. We're ready to install Ghost. Luckily, we don't have to configure nginx. Ghost is going to do that for us. Ghost is going to run on node. We needed node to move forward.

egghead
egghead
~ 8 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today