How to Install and Set Up a Ghost Blog on AWS Lightsail - Step by Step Tutorial
Tags: aws, devops, beginners, tutorial
Published: 2023-10-21 14:14:20

Welcome to this step-by-step tutorial on how to install and set up a Ghost blog on AWS Lightsail. Ghost is a popular open-source publishing platform that is simple, lightweight, and designed specifically for bloggers. With AWS Lightsail, you can easily deploy your own Ghost blog in just a few simple steps.

Feel free to checkout the below video I made for this tutorial as well.

{% youtube mCmqvZyIOwY %}

In this tutorial, we will walk you through the complete process of installing and configuring Ghost on an AWS Lightsail instance. By the end of this guide, you will have your own fully functional Ghost blog up and running.

## Prerequisites

Before we begin, make sure you have the following:

*   An AWS Lightsail account
*   Basic knowledge of AWS Lightsail and its services
*   A registered domain name (Optional)

## Step 1: Create an AWS Lightsail Instance

The first step is to create an AWS Lightsail instance. Here's how you can do it:

1.Log in to your AWS Lightsail account and Click on the **Create instance** button.

![aws-lightsail](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j7j6gpja68qn84lntyft.png)

2.Select your preferred instance location, operating system, and instance plan.

![lightsail-create-1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/23xgf21wnb2ftanlefiz.png)

![lightsail-create-2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c4vpa6u39rcwqbcfsr5k.png)

3.Click on the "Create" button to create the instance.

![lightsail-create-3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d771hrj6tuajgisimshe.png)

Once the instance is created, note down the public IP address of your instance. We will need it later.

## Step 2: Connect to Your Lightsail Instance

To connect to your Lightsail instance, follow these instructions:

Open your terminal or SSH client. Use the following command to connect to your instance:

```
ssh -i path/to/your/key.pem ubuntu@your_instance_ip
```

Replace `path/to/your/key.pem` with the path to your private key file, and `your_instance_ip` with the public IP address of your instance.

## Step 3: Update Packages and Install Dependencies

Once you are connected to your Lightsail instance, update the packages and install the necessary dependencies using the following commands:

```
sudo su
```
```
sudo apt update && apt upgrade -y
```
```
sudo apt-get install nginx mysql-server -y
```
```
sudo ufw allow 'Nginx Full'
```

## Step 4: Install Nodejs, NPM and Ghost-CLI

Next steps is to install nodejs and npm which we'll doing using nodesource github repository:

```
sudo apt-get install ca-certificates curl gnupg -y
```
```
sudo mkdir -p /etc/apt/keyrings
```
```
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
```
```
NODE_MAJOR=18
sudo apt-get update && sudo apt-get install nodejs -y
```

Next up, let's install Ghost-CLI package globally.

```
sudo npm install ghost-cli@latest -g
```

## Step 5: Install and Configure Ghost

Now it's time to install and configure Ghost on your Lightsail instance. Follow these steps:

### Create a new user with required permissions

```
adduser <user>
```
```
usermod -aG sudo <user>
```
```
su - <user>
```

_Note: Using the user name ghost causes conflicts with the Ghost-CLI, so it’s important to use an alternative name._

_Note: replace `<user>` with the username of the username you want to add_

### Create a new directory, set correct permissions and navigate to it for your Ghost blog:

```
sudo mkdir -p /var/www/sitename
```
```
sudo chown <user>:<user> /var/www/sitename
```
```
sudo chmod 775 /var/www/sitename
```
```
cd /var/www/sitename
```

### Install and Start Ghost:

```
ghost install
```

![ghost-setup-1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wn6y7gc3oa5owz3dfkdr.png)

![ghost-setup-2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gaqmq8uzerqs182l8yq4.png)

**During the installation, Ghost-CLI will ask you a series of questions. Provide the following answers:**

*   Blog URL: Enter your domain name (e.g., `https://your_domain.com`).
*   MySQL hostname: Press Enter to use the default value (`localhost`).
*   MySQL username / password: Enter the MySQL username and password you want to use for your Ghost blog.
*   Ghost database name: Enter the name for your Ghost database. You can use the default value.
*   Set up a Ghost MySQL user? (Recommended): Choose "Yes" to create a custom MySQL user for Ghost.
*   Set up NGINX? (Recommended): Choose "Yes" to automatically set up NGINX for your Ghost blog.
*   Set up SSL? (Recommended): Choose "Yes" if you have an SSL certificate for your domain. Otherwise, choose "No".
*   Set up systemd? (Recommended): Choose "Yes" to use systemd as the process manager for Ghost.

## Step 6: Access Your Ghost Blog

To access your Ghost blog, open a web browser and enter your domain name (e.g., `https://your_domain.com`). You should see the Ghost setup page, where you can create your admin account and customize your blog.

![ghost-preview-blog](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/drzp5kxzkycfmez3uu09.png)

## Conclusion

Congratulations! Your Ghost blog is now up and running on your AWS Lightsail instance.

Feel free to checkout the below video I made for this tutorial as well.

{% youtube mCmqvZyIOwY %}

Now it's time to start creating and publishing your own content on your brand new Ghost blog. Happy blogging!

Thank you for reading! If you found this blog post helpful, please consider sharing it with others who might benefit. Feel free to check out my other blog posts and visit my socials!

- [Profile](https://bio.link/devarshishimpi)
- [Linkedin](https://linkedin.com/in/devarshi-shimpi)
- [Twitter](https://twitter.com/devarshishimpi)
- [Youtube](https://youtube.com/@devarshishimpi)
- [Hashnode](https://devarshishimpi.hashnode.dev)
- [DEV](https://dev.to/devarshishimpi)

### Read more

- [Creating Your First Droplet - DigitalOcean Tutorials](https://blog.devarshi.dev/creating-your-first-droplet-digitalocean-tutorials)
- [Top 10 VS CODE Extensions You Need In 2022!](https://blog.devarshi.dev/top-ten-vscode-extensions-you-need-in-twentytwentytwo)
- [Setting Up An Ubuntu EC2 Instance From Scratch on AWS](https://blog.devarshi.dev/setting-up-an-ubuntu-ec2-instance-from-scratch-on-aws)