CodeNewbie Community 🌱

Cover image for How to Install and Set Up a Ghost Blog on AWS Lightsail - Step by Step Tutorial
Devarshi Shimpi
Devarshi Shimpi

Posted on • Originally published at blog.devarshi.dev

How to Install and Set Up a Ghost Blog on AWS Lightsail - Step by Step Tutorial

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.

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

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

lightsail-create-1

lightsail-create-2

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

lightsail-create-3

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
sudo apt update && apt upgrade -y
Enter fullscreen mode Exit fullscreen mode
sudo apt-get install nginx mysql-server -y
Enter fullscreen mode Exit fullscreen mode
sudo ufw allow 'Nginx Full'
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
sudo mkdir -p /etc/apt/keyrings
Enter fullscreen mode Exit fullscreen mode
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
Enter fullscreen mode Exit fullscreen mode
NODE_MAJOR=18
sudo apt-get update && sudo apt-get install nodejs -y
Enter fullscreen mode Exit fullscreen mode

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

sudo npm install ghost-cli@latest -g
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode
usermod -aG sudo <user>
Enter fullscreen mode Exit fullscreen mode
su - <user>
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
sudo chown <user>:<user> /var/www/sitename
Enter fullscreen mode Exit fullscreen mode
sudo chmod 775 /var/www/sitename
Enter fullscreen mode Exit fullscreen mode
cd /var/www/sitename
Enter fullscreen mode Exit fullscreen mode

Install and Start Ghost:

ghost install
Enter fullscreen mode Exit fullscreen mode

ghost-setup-1

ghost-setup-2

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

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.

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!

Read more

Top comments (0)