When I first came across Ghost, self-hosting was a daunting challenge. For a complete beginner having to mess with servers, it's no easy task.

The goal is to allow a complete beginner, without prior experience, to set up a Ghost publication on their own server. Why? Even though Ghost offers a $9/month plan, self-hosting gives you complete control and access to features only available on more expensive plans.

💡
Using Ghost(Pro) funds the organization behind Ghost. So if messing with servers is a no-go for you and you want to support independent publishing, sign up for one of their plans.

Let's dig in.

What you'll need:

  • Domain name
  • DigitalOcean account (with credit or billing set up)
  • Terminal app (or willingness to use DigitalOcean’s browser terminal)

If you're not sure about Ghost yet, test it out on your computer!

How to Install Ghost Locally (Step-by-Step Guide)
Learn how to install Ghost on your computer with just a few steps. Perfect for getting to know Ghost, testing themes and building your website before going live.

Set Up Your Server on DigitalOcean

The first thing you need to start your server is to actually have it. In this guide, we'll use DigitalOcean, a hosting provider for developers. They offer a wide range of products, but we'll focus on those that are somewhat automated for installing Ghost.

  • Set up an account with DigitalOcean. You can use this link to get $200 of credit over 60 days, and once you spend $25, we get $25 in credit.
  • Choose a prebuilt server image for Ghost called a "Droplet". In your account, click "Create" and choose "Droplet". I recommend selecting a region closest to you. Under "Marketplace", search for Ghost and select it.
  • Choose the most basic plan possible. At the time of writing, that's the $12/month droplet.
  • It's recommended you turn on automatic backups, but not necessary. But in case something goes wrong later, you'll be thankful.
  • Either add an SSH key or create a root password. SSH key is generally safer, but you have to create it on your machine first.
  • Name your droplet and click create.
💡
Pro tip: I strongly recommend turning on backups for your droplet. It's a little more expensive but well worth the security. It's not a huge problem if your server breaks down for some reason when you're starting out. But once your publication grows, it won't be very pleasant if you lose all your data (been there, done that).

Connect Your Custom Domain

You've completed the first step, now we have to add your domain.

  • Copy the IP address of your droplet. You can find it in your DigitalOcean profile and paste it in your browser. You should see this (if not, wait):
  • Now we have to add your domain. Click on the 3 dots next to the droplet name and choose "Add a domain". Then type it in (for example, yourname.com). This can also be a subdomain, for example, blog.yourname.com.
  • Click on your domain name. You will see that some DNS records are already created. There, you can see an A record that points your domain to your droplet's IP address.
💡
Pro tip: You can configure your DNS records in such a way that you will manage everything inside DigitalOcean. Just paste the 3 NS records to your domain provider. If you have your domain on Cloudflare, I recommend you use Cloudflare.
💡
Pro tip: You don't have to type the whole domain to your DNS records. For example, if you were to put @ as hostname, this will equal to yourdomain.com. If you put in www this will equal to "www.yourdomain.com".
  • In any case, you need to add an A record to your DNS provider that points to your droplet's IP address. If you use DigitalOcean for this, the work is already done for you. For external DNS providers, you have to add one.
  • Once you complete the steps above, type in your domain into your browser. It could take a couple of minutes, but once it propagates, you should see the same page as we did when we navigated to our IP address.

Learn the basics of domain management in our guide below.

How to Buy a Domain Name for Your Blog
Choosing a domain name is the first big step you take in building your first blog or any website. But before you do it, read these few tips on how to make a good decision for a domain that will last you a lifetime.

Run the One-Click Ghost Installer

Now we have everything in place for starting the automatic Ghost installation. It might be daunting for absolute beginners, but this chapter will guide you through every step you need to take.

You can either use DigitalOcean's in-browser terminal to do this, or the one on your computer, which generally works better. The steps are exactly the same for both.

  • Log into your droplet using your terminal or command line and SSH. Enter the password you chose when buying the droplet.
# SSH into your droplet
ssh root@droplet_ip_address

# When prompted, type in your password and press enter
  • Press enter to begin installation and it will start automatically.
  • When it's finished, you'll have to specify your domain. Type in your non-www domain like this:
yourname.com
  • Next, enter an email address when prompted for your SSL certificate, which is 100% free from Let's Encrypt.

This is it, you are done, my friend!

💡
Pro tip: Using your terminal and SSH is much more enjoyable than using the built-in one from DigitalOcean. Took me long enough to figure this one out.

Before you continue, navigate to your domain in your browser and check that everything is working. Add /ghost to your URL, create an account and set up your website.

💡
Pro tip: The time has come when you can import whatever you already made on your local Ghost installation.

Secure & Configure Your Ghost Installation

The website should now be working. But to ensure Ghost is working properly, we have some more work to do.

Since Ghost CLI 1.5.0 you cannot run ghost commands as the root user or ghost-mgr. We have to create a new user and give it appropriate permissions. You should still be logged into your terminal as the root user.

  • Create a new user and fill in the required data (you really only need the password):
adduser name
  • Give the new user sudo (like administrator) permissions:
usermod -aG sudo martin
  • Move the config file to your new user folder:
# Make a .ghost directory in your user's folder
mkdir -p /home/martin/.ghost/

# Change ownership of that folder
chown martin:martin /home/martin/.ghost

# Move the config file from ghost-mgr to your new user
mv /home/ghost-mgr/.ghost/config /home/martin/.ghost/config

# Change ownership of that config file
chown martin:martin /home/martin/.ghost/config

# Change into Ghost installation
cd /var/www/ghost

# Execute this command
find . -group root -user root -exec chown martin:martin {} \;

# Switch user
su - martin
  • Now we have to change the ownership of the most important folders and files, so you can operate smoothly with Ghost. You have to run commands with "sudo" in front:
# Change ownership of the config.production.json file
sudo chown martin:martin /var/www/ghost/config.production.json

# Change ownership of the .ghost-cli file
sudo chown martin:martin /var/www/ghost/.ghost-cli

# Change ownership of the Ghost folder files
sudo chown martin:martin /var/www/ghost/

# Change ownership of the Ghost versions folder
sudo chown martin:martin /var/www/ghost/versions

# Navigate to /var/www/ghost
cd /var/www/ghost

# Execute this line
sudo find ./ -type d -exec chmod 00775 {} \;
  • That should do it. Just make sure you're meticulous with what you write in the terminal. Now try restarting and updating Ghost to see if everything is working as it should be.
💡
Pro tip: The only folder that isn't owned by your new user is the "content" folder. That one has to be owned by "ghost"

Keeping Your Ghost Updated

The only thing you really need to manage the server is knowing how to update Ghost CLI and Ghost. It's simple.

  • To update Ghost CLI as your newly created user, SSH into your droplet like above and make sure you're not in your Ghost installation folder (remember how we installed Ghost CLI on our local computer).
# Update Ghost CLI

sudo npm install -g ghost-cli@latest
  • Ghost updates are pretty regular, so you should just try and update it every few days or weeks. To update Ghost, you have to navigate into the folder where it's installed and execute this line:
# Navigate into Ghost folder
cd /var/www/ghost

# Update Ghost
ghost update

Summary

  1. Create a DigitalOcean account with this link to get $200 of credit over 2 months. Choose the least expensive droplet and turn on backups.
  2. Add your domain and configure DNS records to manage everything in one place.
  3. Ghost will install automatically on this droplet, so you just need to configure it.
  4. Create a new user and give it the correct permissions. Make sure to be meticulous with what you write. Choose the non-www domain as the main one.
  5. Learn to update Ghost CLI and Ghost.