How to Host a Ghost Blog on Fly.io for Free

Ghost is a CMS that is open-source, which means you can use it to make blogs and websites. It uses JavaScript for its code, and you have the choice to host it yourself or on a cloud service. In this guide, we are going to deploy Ghost blog on Fly.io. This platform helps developers to launch and scale their applications easily. With Fly.io, you can distribute your application across different regions without difficulty. Their complimentary package provides 3 virtual machines, each with 256 megabytes of memory and 3 gigabytes of lasting storage - this should suffice for running a small blog.

How to Host a Ghost Blog on Fly.io for Free; Source: XTA Blog

How to Host a Ghost Blog For Free

To start a ghost blog without cost is easy with the help of an app deployment platform named Fly.io. You should have a shared IP and use a shared machine, then follow these steps:

  1. Install the Fly.io command line interface
  2. Sign up for Fly.io
  3. Deploy Ghost using the pre-made Docker image
  4. Configure an SQLite database to store the Ghost data
  5. Configure your blog
  6. Set your ghost blog live
  7. Create a ghost account

Let us go over each of these steps in greater detail to help you get started.

Ghost Blog; Source: The Autodidacts

1. Installing the Fly.io Command Line Interface (CLI)

First, we must set up the command line tools for Fly.io so that we can put out the application.

Run the following commands in your command prompt or terminal to accomplish this:

Windows:

curl -L https://fly.io.install.sh | sh

Mac with Homebrew:

brew install flyctl

(If you don’t have homebrew installed on your mac, run the following command first)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. Create a Fly.io Account

After the Fly.io CLI is installed correctly, we must make an account for deploying.

Execute this command to start a browser for making an account.

flyctl auth login

Once you make an account with your email or GitHub, it is necessary to provide payment information before making any resources.

Fly.io offers a good amount of free services, so you will not go over your limit if you are hosting a Ghost server on your account. However, they ask for your credit card information in case you choose to upgrade your package in the future.

Once you are logged in successfully, you can go back to the command line and keep going with the deployment of the ghost app.

3. Deploying Ghost Using the Pre-Made Docker Image

Now, we will make an application on Fly.io for running the most recent Ghost docker image.

If these words seem like complicated technical language to you, then there is no need for concern because they will not impact the blog after you have completed the setup. Continue to read and follow each step and everything will be okay.

We must make a new folder on the computer so that we can keep all the setup files in it. For this case, let's name the folder "blog".

mkdir blog

cd blog

flyctl launch --image=ghost --no-deploy

To configure your Fly.io instance, please obey the steps shown on the terminal display.

During a stage of the setup, you will need to provide a name for your application. This name should be distinct across all sites on Fly.io, so it might require attempting various names until one is accepted.

Make sure to remember this name, as you’ll need it for some steps later.

4. Configure an SQLite Database to Store the Ghost Data

Next, we must make a database for keeping your blog articles inside (Fly.io refers to this as a volume).

To create a 3GB volume called data for the instance, run the following command: 

flyctl volumes create data -s 3

Ensure you select the identical region where your Ghost setup exists while adhering to the guidelines.

5. Configure Your Blog

We must edit a configuration file before we can publish our blog on the internet.

In the directory you made not long ago, which we refer to as "blog" in this guide, please open the file named fly.toml by using Notepad or TextEdit if you are on a Mac computer, and then make changes to certain parts.

[env]

  url = "https://blog.fly.dev"

  database__client = "sqlite3"

  database__connection__filename = "content/data/ghost.db"

  database__useNullAsDefault = "true"

  database__debug = "false"

[mounts]

  source="data"

  destination="/var/lib/ghost/content"

[[services]]

  internal_port = 2368

If some section headings, like [env], are already in the file, you should simply put the configuration values underneath them.

Ensure you substitute the URL in the configuration with the name assigned during the creation of your fly application.

If the name of your deployment is my-new-blog, then change the url to "https://my-new-blog.fly.dev".

6. Set Your Ghost Blog Live

After the blog setup is complete, you can make it go live by executing this command:

flyctl deploy

The procedure typically lasts some minutes, therefore you are welcome to prepare a cup of coffee during this interval.

After it is finished, you can visit the website of your blog (for example https://my-new-blog.fly.dev) to view your newly created Ghost blog.

7. Create a Ghost Account

To change how your blog appears and to write new posts, you must make an account.

For this action, please navigate to yourBlog.fly.dev/ghost in the search bar and input your information.

How to Set Up a Custom Domain For My Free Ghost Blog

Hosting a Ghost Blog; Source: ByteDistro

To use a custom domain for your project, like typing soloinnovator.com to reach this blog instead of soloinnovator.fly.dev, please continue reading.

Going forward in this guide, I assume you've purchased a domain name and can modify DNS records in the necessary control panel. If not, it would be helpful to look up how to do that with a quick search on Google.

Register the Domain on Fly.io

First, please execute these commands within the directory you were previously using, substituting host.com for your chosen domain name.

fly domains add host.com

fly certs add host.com

After running this command, you will see an output like the one below

You are creating a certificate for host.com

We are using lets_encrypt for this certificate.

You can direct traffic to host.com by:

1: Adding an A record to your DNS service with the following text:

A @ XX.XX.XX.XX

You can prove your ownership of host.com by doing the following:

2: Adding the following AAAA record to your DNS service:

AAAA @ XXXX:XXXX:X::X:XXXX

To set up the fly custom domain, you must insert both A and AAAA records into your DNS by following these steps.

Please know it usually requires approximately 15 minutes to check the domain and give out an https certificate.

Update the Config and Redeploy

While you wait for the creation of certificates, please open the configuration file named fly.toml and change the url parameter to match your newly made certificate.

Run the following command after updating this value to redeploy your ghost application.

flyctl deploy

The process for moving the website could take several minutes, after which you should be able to visit the site with your new domain name.

How to Set Up the Transactional Mailer

To send basic emails like notifications and signup confirmations from Ghost, the transactional mailer requires setup through SMTP. For setting this up, you need to insert certain configuration details under the [env] section in your fly.toml file; make sure you fill out these details with your own SMTP server information.

[env]

  mail__from = "..."

  mail__transport = "SMTP"

  mail__options__host = "..."

  mail__options__port = ...

  mail__options__auth__user = ...

  mail__options__auth__pass = ...

You need to set up bulk emails, like newsletters, in the Ghost admin panel and use Mailgun for it.

Conclusion

Ghost is a fantastic platform for people who create content, offering many features to manage a blog, newsletters, and subscriptions with ease. It's truly enjoyable to use. If you have ever felt a strong desire to remove your own eyes following an attempt to use WordPress, you really should consider trying Ghost.

Fly.Io is a good platform for launching applications, which lets you deploy your apps easily in several parts of the world close to where your customers are. They have very helpful command-line tools that make it easy to manage and launch programs consistently and reliably.

If you have followed many of these steps correctly, your new blog should be working now. Go to https://your-domain-name.Fly.Dev/ghost and start making your content!



How much is a great User Experience worth to you?


Browsee helps you understand your user's behaviour on your site. It's the next best thing to talking to them.

Browsee Product