Install and Start Ghost on an AWS EC2 Instance Connected to AWS RDS

Sam Julien
InstructorSam Julien
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 4 years ago

We have everything ready to finally install Ghost! To do the installation, we will need to write one big command to set up Ghost with our AWS RDS database.

First, we'll collect all of the config variables that we need and then pass those variables into the ghost install command. After we do that the CLI will ask us a few more questions before Ghost is completely set up.

Instructor: [0:00] We're ready to install Ghost and get it up and running on our EC2 instance. In order to do that we're going to use one big command with a bunch of configuration in it. You're going to need to gather a couple of pieces in it of information and have them ready for when you're entering that command.

[0:15] The first thing you're going to need is the EC2 public IP address. Go over to EC2. Click on Instances. Let's move this down a little bit. Select your Ghost server, and grab this public IP address. You're going to want to paste it into something like Notepad or Drafts, or something like that.

[0:34] The next thing you're going to need is the database information. You should have your credentials from a previous video saved somewhere. Go ahead, and grab those. You're also going to need the connection strings. If we go over to our Console Home here, click on RDS. You can also get to RDS by opening up the Services Menu and going to RDS there.

[0:54] Wait for RDS to load, and then head over to DB instances. Click on your database, and you can see we've got this endpoint here. This is the endpoint that you're going to need. Copy that over. Put that in the same spot that you're keeping your public IP address.

[1:11] You're going to need the connection string, the user password, and database name, and also the public IP address for this command. Gather all those up in one place and then let's head over to the terminal.

[1:23] In the terminal, you can see that I am in our Ghost directory that we created, and I'm logged in as Ghost Admin. Let me clear this out, and we're going to do a quite long command here, so bear with me.

[1:36] We're going to say ghost install, and we're going to use these slashes to let us get onto new lines without executing the command. I'm going to do this, / and hit enter. That's going to give me a new line.

[1:48] I'm going to say, --db=MySQL, another /, then we're going to say, --dbhost=, and this is going to be our connection string to RDS. Grab that and then paste that in. Now, before you hit enter, add another /. It's always very tempting to hit that enter right after you paste something. It's muscle memory at that point.

[2:09] Add another /, hit enter again. Do another flag, --dbuser. In mine, I set it up for Ghost Admin. This is why in that previous video, I talked about special characters, because this can get weird as you're trying to enter in this command for the installation process if you have a bunch of special characters.

[2:28] Add another /, hit enter, --dbpass=, and I made it simple. This is a very insecure password, but for now, it's OK. We can always change it later. Add another /, hit enter, and then do --dbname, and put in the name of your database. I had done, Ghost-Database.

[2:48] Then double-check all that, make sure it's right. Go ahead and hit enter, and the Ghost-CLI will start doing its thing. It's going to check all of the prerequisites. It's going to make sure that it can connect to the database. It's going to do a whole bunch of things for you.

[3:01] The Ghost-CLI is really nice. It used to be, you had to do all of this stuff manually. It was quite a process, so it's awesome now that you can do this in a single command. Even when you're not installing the database locally, you're actually connecting to another database somewhere else, like we're doing with RDS.

[3:15] Let's let that install. Once it finishes downloading and installing Ghost, it's going to walk you through this wizard here. This is where you need the public IP address for your EC2 instance.

[3:25] We're going to type in, and this is very important, add the http://. Don't just type in the numbers for the IP address. The IP address for my EC2 instance, which will be different than yours, is 18.188.240.246. Then hit enter. We have to add the sudo password here.

[3:47] I can't scroll to make this easier to see, but the next question is, do you wish to set up NGINX? We want to say yes for that. It's going to tell us that SSL certs cannot be generated for IP addresses, and it's going to skip that. That is totally normal, because we're not using a custom domain with https.

[4:04] The next question is, do you want to set up systemd? Systemd is a standard process for controlling what programs run when a Linux system boots up. We want to say yes, because we want Ghost to run every time this machine is started up.

[4:17] Lastly, it's going to ask us if we want to start Ghost. We'll go ahead and say yes to that. That's going to start up Ghost for us, and now you can see we get this nice message that says, Ghost was installed successfully. To complete the process of setting up the actual blog, we could go over to this IP address.

[4:34] For the sake of gratification, let's go ahead and copy that over, head over to the browser, and open a new tab. Paste that in, and you can see we've done it. We've installed Ghost and can set up a blog with Ghost running on our EC2 instance and our RDS instance. Congratulations.

[4:53] I'll leave you to walk through the setup process with Ghost since it'll be specific to however you want to use it, but what's cool is that as you're going through this process, it's going to be creating and modifying tables and entries on your RDS database.

[5:07] You should feel great about the fact that you've started this from scratch and got all the way through to being able to use a UI to modify an RDS database.