Chris Mendez in For Developers, Homebrew

How to install Ghost Blog on your local computer

!!! DEPRECATED !!!

This article was designed for older versions of Ghost such as Ghost 0.11.1. If you are planning to install the latest version of Ghost, read this article.


The Ghost Blogging Platform is excellent. It's 100x's simpler than Wordpress and for most bloggers, all you really need. In fact, unless you are a publisher (who sells advertising), Ghost is the best tool for the price; free.

Although the Ghost CMS is free, it takes a little bit of work to figure out how to install and deploy it on a hosted server. I thought it would be as easy as downloading a development-tool-in-a-box like MAMP and then placing the folder into an /htdocs –similar to how you could install Wordpress.

Nevertheless, here is my cheatsheet on how to install Ghost on my local computer.


Step 0 - Getting Started

I prefer to use a package manager like Homebrew to install and uninstall 3rd party libraries. Since I'm on a Mac, I use Homebrew.

Here a quick tutorial on how to install Homebrew on a Mac.

Step 1 - Install MySQL

Install MySQL version 5.5.

brew install mysql@5.5  

There are a suite of Homebrew helper commands you can use to start and stop your MySQL databases. You can install these services using through the tap command.

brew tap homebrew/services  

Start your database.

brew services start mysql  

Update your package manager and double check that everything is working.

brew update && brew doctor  

Note: If you need more help on this section, I suggest reading this article and this article.

Step 2 - Install Node and Grunt

I suggest reading this article on how to install an older version of Node such as version 4.5.

brew install node@4  

The developers of Ghost decided to use Grunt to manage the Ghost installation. Are are installing it globally -g to keep things simple.

npm install -g grunt  

Step 3 - Download Ghost

Download Ghost Blog

Step 4 - Run Grunt

Change directory to your Ghost package.

cd ./path/to/ghost/folder  

Run the grunt command.

grunt init --force  

Step 5 - Install more libraries

The next step will be to install more libraries found within package.json.

npm init  

Time to run the Ghost Blog.

npm start  

Step 6 - Ta Da!

Visit the Ghost Start Page


Configuring your database for MySQL

By default, Ghost uses SQLite for its database. SQLite is excellent but you may want to set it up for MySQL. All you need to do is modify the ghost-folder/config.js file.

In this example below, I've commented out the reference to SQLite and replaced with with a simple reference to mysql with a database name of blog.

 // ### Development **(default)**
development: {  
    url: 'http://localhost:2368',
    // Good for development, bad for production.
    forceAdminSSL: false,
    // Mailgun.com
    mail: {
        transport: 'SMTP',
        options: {
            service: 'Mailgun',
            auth: {
                user: 'myemail@chrisjmendez.com',
                pass: 'xxxxxxxxxxxxxxxxxxxxxxxx'
            }
        }
    },
    // MySQL
    database: {
        client: 'mysql',
        connection: {
            host: 'localhost',
            user: 'ghost',
            password: 'password',
            database: 'blog',
            charset: 'utf8'
        },
        debug: true
    },
    // #### Server
    // Can be host & port (default), or socket
    server: {
        // Host to be passed to node's `net.Server#listen()`
        host: '127.0.0.1',
        // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
        port: '2368'
    },
    // #### Paths
    // Specify where your content directory lives
    paths: {
        contentPath: path.join(__dirname, '/content/')
    }
}

Configuring Ghost to send e-mail

If you notice in the example above, I included how to configure Mailgun with your Ghost Blog. You can probably do something similar for Sendgrid.

development: {  
// Mailgun.com
mail: {  
    transport: 'SMTP',
    options: {
        service: 'Mailgun',
        auth: {
            user: 'myemail@chrisjmendez.com',
            pass: 'xxxxxxxxxxxxxxxxxxxxxxxx'
        }
    }
}

Troubleshooting

Other Libraries

While running Grunt for the first time, I discovered that I needed to install a few other libraries.

npm install -g knex-migrator  
knex-migrator init  

Resources