Deploy a Ghost Blog on Simple Hosting

This tutorial will show you how to deploy a Ghost blog on a Node.js Simple Hosting instance.

What is Ghost?

Ghost is a free and open source blogging platform written in JavaScript and distributed under the MIT License, designed to simplify the process of online publishing for individual bloggers as well as online publications.

Prerequisites

In order to deploy a Ghost blog you will need:

  • A Simple Hosting instance using Node.js and MySQL
  • A domain name where you will host your instance
  • Access to a command-line terminal with git and ssh installed

Create a Site on your Simple Hosting Instance

The first step is creating a site on your Simple Hosting instance. Do this by going to your Simple Hosting interface.

Next, click on the name of the instance you want to use to deploy your Ghost blog.

Click on the “Sites” tab, then click “Start” or “Create a site.”

Enter the name of the site you want to create. For example, you may want to use something like “blog.example.com.”

Warning

Make sure your domain is spelled correctly, since a typo can make your site inaccessible.

After you type in your name our system will validate that you have the right to use the domain name. If your domain is using our LiveDNS nameservers, then this should only take a few seconds. Otherwise follow the prompts for adding a TXT record at your DNS provider in order to validate your use of the domain.

After your domain has been validated click “Activate now” to publish the address.

You can then confirm your site is available by going to the address you defined above, such as blog.example.com. You should see a page displaying the text “It works…”

Create a Database for the Ghost Blog

Next, you will create a database on your instance for your Ghost blog.

To do this, go to the “Administration” tab for your Simple Hosting instance. Find the “Database” section on this page.

Click on “Go to phpMyAdmin” to manage your databases.

When you open phpMyAdmin you will be prompted for the instance username and password in a dialog box. These are explained below:

  • The instance username. This is a 7 digit number that was automatically generated when you created your instance. You can find it in at the top of the “Administration” tab in the Gandi interface for your page, the same page where you found the link to phpMyAdmin.
  • The instance password. You provided this password when your instance was created. If you don’t remember the password you can change it at the top of the “Administration” tab in the Gandi interface for your page, the same page where you found the link to phpMyAdmin.

When you reach the phpMyAdmin page you will log in using your database username and password. This is different than the username and password for your instance. By default the username will be “root” and the password will be empty.

Once you have logged into phpMyAdmin click on “Databases.” At the top of the page is a box for creating databases. Give your Ghost blog database a name, such as “ghost_db”, then click “Create.” Remember the name of the database you used, since you will need it when you set up your Ghost blog.

Download Ghost Source Code and Setup Git Repository

From your local computer, create a directory for your Ghost blog, and download the latest release.

$ mkdir ghost_blog && cd ghost_blog/
$ wget https://github.com/TryGhost/Ghost/releases/download/3.23.0/Ghost-3.23.0.zip
$ unzip Ghost-3.23.0.zip
$ rm Ghost-3.23.0.zip

Next, locate the deployment details for your Simple Hosting instance. This information is provided in your Gandi account under “Simple Hosting -> Your Instance -> Sites -> blog.example.com -> Deploy with git”.

On your local machine, while inside your ghost project folder, initialize a git repository :

$ git init

Then execute the “Remote configuration” command that you located just earlier, which will look something like this :

$ git remote add gandi git+ssh://{instance_id}@git.{datacenter_id}.gpaas.net/default.git

Edit config.production.json

Using your favorite text-editor, edit the the core/shared/config/env/config.production.json file.

Ensure to provide your Site address (ex. blog.example.com), a valid FROM email address (ex. me@example.com), and the name of your database (ex. ghost_db).

You can use the following template, which we recommend starting from as it includes the appropriate Simple Hosting socketPath for MySQL, and port value :

{
 "url": "http://blog.example.com",
 "server": {
     "port": 8080
 },
 "mail": {
     "from":"me@example.com"
 },
 "database": {
     "client": "mysql",
     "connection": {
         "socketPath"     : "/srv/run/mysqld/mysqld.sock",
         "user"     : "root",
         "password" : "",
         "database" : "ghost_db"
     }
 },
 "paths": {
     "contentPath": "content/"
 },
 "logging": {
     "level": "info",
     "rotation": {
         "enabled": true
     },
     "transports": ["file", "stdout"]
 }
}

After modifying your custom parameters, save and close the file.

Commit, Push, and Deploy

Commit and push the code to your git repository:

$ git add .
$ git commit -am 'first commit of ghost blog'
$ git push gandi master

Then deploy the code using the “Deploy” command that you located earlier, which will look something like this :

$ ssh {instance_id}@git.{datacenter_id}.gpaas.net deploy default.git

The deployment process will take a minute or two to complete.

That’s it! Your Ghost blog should be up and running. You can navigate to the /ghost path (ex. blog.example.com/ghost) to setup your adminstrative user account.