Skip to the content.
15 November 2022
## Overview [Ghost](https://ghost.org/) is a fast, open-source publishing platform built on Node.js. While there are dozens of content management systems available, Ghost is a popular choice for developers because it is highly customizable, optimized for search engines out of the box, and incredibly fast. In this guide, we will set up a fresh Ghost blog using [SQLite](https://www.sqlite.org/index.html) as our database, configure automatic streaming backups, and add a commenting system powered by [GitHub issues](https://docs.github.com/en/github/managing-your-work-on-github/about-issues). ## Key points - Set up a blog using Ghost CMS. - Use SQLite as the database and configure automatic backups. - Enable article comments using GitHub issues. ## 1. Set up Ghost CMS First, choose your cloud host and virtual machine operating system. While Ubuntu Server is officially recommended by Ghost, [Debian](https://www.debian.org/) is an excellent, lightweight alternative that is highly stable and consumes fewer system resources. For cloud hosting, a few cost-effective options include: - [AWS Lightsail](https://aws.amazon.com/lightsail/) - [Google Cloud Platform](https://console.cloud.google.com/marketplace/product/click-to-deploy-images/ghost) - [Azure](https://docs.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-portal) - [Digital Ocean](https://marketplace.digitalocean.com/apps/ghost) AWS Lightsail is often the most economical. A starter instance costs around $3.50 a month, which is perfect for new blogs, and you can easily scale the instance as your traffic grows. Before starting, open ports `80` (HTTP) and `443` (HTTPS) in your hosting provider's firewall settings. > If you choose Ubuntu, prepend `sudo` to the commands below. If you choose Debian, run system administration tasks as root. ### Install system updates ```bash # Run as root or with sudo apt update apt upgrade -y ``` ### Install Node.js ```bash # Run as root or with sudo curl -fsSL https://deb.nodesource.com/setup_16.x | bash - apt install -y nodejs ``` ### Install Nginx ```bash # Run as root or with sudo apt install nginx ``` > **Note:** Map your domain name (e.g., `techflak.com`) to the public IP address of your server in your DNS provider settings (like Route53 or GoDaddy). Wait for the DNS records to propagate before configuring your SSL certificate with Let's Encrypt. You can verify it is working by opening your domain in a browser; you should see the default Nginx welcome page. ### Install Ghost CLI and Ghost ```bash # Run as root or with sudo npm install ghost-cli@latest -g # Create a home directory for your website sudo mkdir -p /var/www/techflak.com sudo chown : /var/www/techflak.com sudo chmod 775 /var/www/techflak.com # Change to the new directory cd /var/www/techflak.com # Run the installer with SQLite specified ghost install --db=sqlite3 ``` The installation wizard will ask a few setup questions. At the final step, when asked if you want to start Ghost immediately, select **"no"**. We need to install the SQLite module manually first. ```bash # Run inside your site directory /var/www/techflak.com npm install sqlite3 --save # Start Ghost ghost start ``` Your blogging platform is now live. You can log in, clean out the default starter articles, and start writing. ## 2. Configure SQLite backups Backups are critical for protecting your data. In database engines like MySQL or PostgreSQL, you have built-in replication tools. Because SQLite is a single, local file, copying the file while Ghost is running can corrupt it. [Litestream](https://litestream.io/) solves this problem. It is a lightweight backup and replication utility designed specifically for SQLite. It continuously streams changes from your database file to any S3-compatible cloud bucket or local directory, allowing you to restore your database up to the moment of a crash. ### Install Litestream Run the following commands to install Litestream: ```bash wget https://github.com/benbjohnson/litestream/releases/download/v0.3.3/litestream-v0.3.3-linux-amd64.deb sudo dpkg -i litestream-v0.3.3-linux-amd64.deb sudo systemctl enable litestream ``` ### Back up to local file system Open `/etc/litestream.yml` and configure your backup path: ```yml dbs: - path: /var/www/techflak.com/content/data/ghost.db replicas: - path: /backup/db ``` ### Back up to AWS S3 Alternatively, you can replicate directly to an S3 bucket: ```yml dbs: - path: /var/www/techflak.com/content/data/ghost.db replicas: - url: s3://mybkt.techflak.com/db region: us-east-1 access-key-id: AKIAxxxxxxxxxxxxxxxx secret-access-key: xxxxxxxxxxxxxxxxxxxxxx ``` After updating the configuration file, start the service to begin streaming your database changes: ```bash sudo systemctl start litestream ``` ## 3. Enable comments with GitHub issues Ghost does not include native article comments out of the box. A few common integration options are: - [Utterances](https://github.com/utterance/utterances) (Open-source, free, and ad-free) - [Isso](https://github.com/posativ/isso/) (Self-hosted comment engine) - [Disqus](https://help.disqus.com/en/collections/191671-installation) (Ad-supported and tracks user data) Utterances is an elegant, lightweight solution for technical blogs because it uses GitHub issues for comment storage and does not require running a separate server. To configure Utterances: 1. Create a public GitHub repository named after your domain (e.g., `username/techflak.com`). 2. Install the [Utterances App](https://github.com/apps/utterances) and grant it access to that repository. 3. Open your Ghost admin panel, navigate to **Settings > Code injection**, and paste the following script into your blog footer: ```html ``` Comments will now render at the end of each blog post. ### Customizing comment placement If the comments do not line up perfectly with your blog theme, you can write custom JavaScript to target a specific HTML container. Most Ghost themes use a container element with the class `.post-full-comments` or `.comments`. Paste this script into your Ghost footer settings: ```js function setupComments() { var container = document.getElementsByClassName("post-full-comments")[0]; if (container) { container.innerHTML = ""; var script = document.createElement("script"); script.setAttribute("src", "https://utteranc.es/client.js"); script.setAttribute("repo", "/techflak.com"); script.setAttribute("issue-term", "pathname"); script.setAttribute("theme", "github-light"); script.setAttribute("crossorigin", "anonymous"); script.setAttribute("async", true); container.prepend(script); } } setTimeout(setupComments, 0); ``` ## Conclusion Ghost is an exceptionally fast, SEO-friendly blogging platform that takes the friction out of publishing. Running it on SQLite makes deployment and server maintenance simple, while tools like Litestream keep your data secure without the complexity of a dedicated database server.