Blogging platforms allow you to express your thoughts and opinions to the world at large—no matter what your area of expertise or interest, you can push your know-how out there and have it read by thousands, or even millions of people. Ghost is one of the best blogging platforms and content management systems available, and with a little effort, you can use Ghost to help you create and administer a blog from your Raspberry Pi.

Why Ghost Is One of the Best Blogging Tools for Raspberry Pi

Ghost's main claim to fame is its simplicity, and developers claim that the Ghost blogging experience is focused on providing the best possible writing and publishing experience. Unlike WordPress, where functionality is enhanced by paid and free plug-ins, Ghost offers most of what you need baked into the base package.

If you're planning on monetizing your blog, these tools can be invaluable, and include the ability to publish both via the web and email newsletter. Delving further into Ghost's features, you'll find the ability to set up a membership system, and paid subscriptions—you can easily turn your blog into a business.

Best of all, while Ghost does offer scalable paid hosting for between $9 and $2,500 per month, the software is open source—meaning that you are free to download, modify, redistribute, or install it on your own hardware. We’ll show you how to install it on your Raspberry Pi.

How to Install Ghost on a Raspberry Pi

Before you begin, you will need to follow our tutorial on how to prepare your Raspberry Pi as a server. Once that's done, visit your registrar's Advanced DNS settings page. Delete all records and create a new A record. Set the host to "@", the value to your public IP address, and the TTL as low as possible.

If you are going to access Ghost through a subdomain, e.g., ghost.improbable.guru, you will instead set the A record to "ghost". Log into your Raspberry Pi using Secure Shell (SSH), then update any upgrade and installed packages:

        sudo apt update
sudo apt upgrade

Now enable these two Apache mods and restart Apache:

        sudo a2enmod proxy proxy_http
sudo service apache2 restart

Change directory, and use nano to create a new Apache conf file:

        cd /etc/apache2/sites-available/
sudo nano ghost.conf

…and enter:

        <VirtualHost *:80>
ServerName ghost.your-domain.tld
ProxyPass / http://127.0.0.1:2368/
ProxyPassReverse / http:/127.0.0.1:2368/
ProxyPreserveHost On
</VirtualHost>

Save and exit nano with Ctrl + O then Ctrl + X.

Enable the conf with:

        sudo a2ensite ghost.conf 

…and restart Apache again.

        sudo service apache2 restart

Add a Database

Ghost needs a database in order to work, so enter MariaDB:

        sudo mariadb

Create a new user called ghost, a new database called ghost, then allow the ghost user to use the ghost database:

        CREATE DATABASE ghost;
CREATE USER ghost IDENTIFIED BY 'topsecretpassword'
GRANT USAGE ON *.* TO ghost@localhost IDENTIFIED BY 'topsecretpassword'
GRANT ALL privileges ON ghost.* TO ghost@localhost;
FLUSH PRIVILEGES;
quit;
mariadb ghost user and database creation

Install Node.js

Move to your home directory, and enable the NodeSource repository, then install Node.js and Node package manager (npm):

        cd ~
curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -
sudo apt install nodejs

Typing:

        node --version

…should reveal your Node version. In our case, the output is v16.17.0. Yours may be different.

Install Ghost

Use npm to install the Ghost installation tool:

        sudo npm install ghost-cli@latest -g

Change directory, then create a new directory called ghost:

        cd /var/www/
sudo mkdir ghost

Move into the new directory, then use the Ghost installation tool to install Ghost:

        ghost install

System checks will fail with the warning that "Linux version is not Ubuntu 16, 18, or 20", but you can safely ignore this and type y to continue. A second message will warn you, "Local MySQL install was not found or is stopped". Keep your nerve and tap y to skip the MySQL check and continue. Ghost will now download and install. On our test Raspberry Pi, this process took around 10 minutes.

A terminal with system check warnings

Set Up Your Blog Account

Once completed, you will be asked for your blog URL, as well as details of your MySQL database. As you installed MariaDB rather than vanilla MySQL, these details will be the ones you set for MariaDB. Your hostname will be localhost, your MySQL username will be ghost, and your MySQL database name will be ghost, and the password will be the fiendishly difficult database password you set earlier. When asked "Do you wish to set up Systemd", type y, then y again when queried whether you want to start Ghost.

Open a browser and visit your-domain-name.tld/ghost/. You will be prompted to create the first account, so fill in the fields with the site name, your name, your email address, and a password. Ghost will insist on a password of at least ten characters; be sure to create a password that is secure and memorable.

ghost initial account creation reading, "welcome to Ghost"

Click on Create account and start publishing to proceed to your site. As soon as you do this, you will receive an email from noreply@your-domain.tld, telling you that your new account has been created.

Before you go any further, you need to secure your Ghost installation with SSL from Let's Encrypt.

        sudo certbot

Enter your email address when requested, and select which name would you like to activate HTTPS for.

Certbot will fetch and install SSL keys and certificates from Let's Encrypt. Now restart Apache:

        sudo apache2 restart

When you reload the page in your browser, the connection to your Ghost blog will be secure, and you will need to log in again.

Building a Website With Ghost on Your Raspberry Pi

As the developers state, Ghost is very intuitive to use, and there will already be an auto-generated home page with your site title, a dummy post, and a readable "About" page declaring your Ghost site to be an independent publication by you, and the date of initiation.

Front page editing interface in Ghost

The admin page is accessed through your-domain.tld/ghost/ and the website admin tools are on the right side of the screen. To create a new post, simply click +. The editor itself is a minimalist WYSIWYG block editor similar to that of WordPress, and is easy to use with no distractions.

From the dashboard, you can add members, create mailing lists, view engagement, and customize your Ghost site.

A web page showing settings for website, members, and advanced. Post controls are on the left side

You Can Easily Install the Ghost Blogging Platform on Your Raspberry Pi!

Ghost is one of many easy-to-install self-hosting projects for the Raspberry Pi. It costs you nothing to install and nothing to run. Why not create a new blog based around your adventures in the exciting world of Raspberry Pi self-hosting projects?