Installing Ghost on Azure

First post from my freshly minted Ghost installation on Azure!

For those not familiar with Ghost, it is an open source blogging platform that started out as a kickstarter project. There are loads of other content management systems out there (e.g. WordPress), but what I like about Ghost is:

  • Content creation is elegant and simple.
  • The platform itself is neatly packaged. As Ghost by default uses SQLite, all that is required for your hosting server is support for Node.js.

Installation

The process of getting Ghost installed as an Azure website was relatively straightforward and I found two options of doing so:

  1. Use the Ghost image from VM Depot
    • Difficulty Level: Extremely Easy
    • Time Required: 5 minutes
  2. Deploy from the Ghost source
    • Difficulty Level: Easy
    • Time Required: 10 minutes

VM Depot

The Bitnami image available through the VM Depot is preconfigured with the entire Ghost stack and is ready out of the box. All that is left to do is deploy it to your web site.

Tools Required:

  • Windows Azure Account

Steps:

  1. From the Azure Management Portal, create a new website from the Gallery.
  2. A pop-up window will appear, choose Blog --> Ghost.
  3. Follow the wizard and create your website.
  4. Done.

From Source

This is a little bit more hands-on but will give you a lot more control over your Ghost instance.

What we are going to do is get a fork the Ghost source code, make our own revisions, persist those revisions to one of the Azure supported source control repositories, and setup continous deployment with Azure.

Tools Required:

  • Git
  • Node.js
  • Source Control Repository (for this example, I'm using GitHub)
  • Windows Azure Account

Steps:

  1. Create a copy of the Ghost Ghost source code

    • Fork the Ghost repository and clone it to your local machine.

      # Cloned my forked Ghost repo
      # Replace the repo URL with your own
      > git clone https://github.com/jpoon/Ghost.git 
      
      
      # If you are adventurous and want to be on
      # the bleeding edge, you can skip this step.
      # Otherwise, let's work out of the stable branch
      > git checkout --track origin/stable
      
  2. Setup Ghost

    # download and install all required node modules
    > npm install
    
    
    # performs task such as retrieving 
    # bower packages, preps CSS/JS
    > grunt init
    > grunt prod
    
  3. Configure Ghost

    # Rename and update config.js
    > git mv config.example.js config.js
    
    • Configure config.js to your likings. For starters, change the production settings:

      production: {
          url: 'http://[[BLOG_URL_HERE]].com', 
          mail: {},
          database: {
              client: 'sqlite3',
              connection: {
                  filename: path.join(__dirname, '/content/data/ghost.db')
              },
              debug: false
          },
          server: {
              host: '127.0.0.1',
              port: '80'
          }
      },
      
    • Here's mine for reference: config.js.

    • Azure currently doesn't support compilation of node packages in the cloud so we'll have to check in the compiled binaries:

      • Update .gitignore, commenting out the following lines:

        #/core/client/assets/css
        #/core/client/assets/fonts
        #/core/build
        #config.js
        
      • Check in all the compiled binaries:

        > git add -A
        > git commit -m [[COMMIT_MSG_HERE]]
        > git push
        
    • At this point you should have a working Ghost installation. From the root directory, start the Node.js app with npm start.

  4. Customize Azure Deployment Script

    • We can configure the deployment script Azure uses to deploy our website. This step is optional. Left unconfigured, Kudu, the git deployment engine used for Azure websites, will synchronize files from your Git repo to your /wwwroot.

      > npm install azure-cli --global
      
      
      # Generate the deployment scripts which will create:
      # 1) .deployment
      # 2) deploy.sh or deploy.cmd (depending on your OS)
      > azure site deploymentscript –-node  
      
    • Configure deploy.sh or deploy.cmd to your liking. Here's mine.
    • Be sure to commit/push these files to the repo once you are done.
  5. Setup Azure website with continuous deployment

    • From the Azure Management Portal, create a new website: New --> Computer --> Website --> Custom Create.
    • Be sure to select the 'Publish from source control option'.
    • Follow the wizard.
  6. Done.

Tips

  • Your blog's administrator portal is available at http://[YOUR_BLOG_URL]/ghost. The portal will allow you to create/edit/delete new posts and modify general settings for your blog.

  • Once you have logged in to the admin portal, you can also export/import your blog settings and data here: http://[YOUR_BLOG_URL]/ghost/debug.

  • You can also retrieve the Sqlite database from your server. To do so:

    1) From the Azure management console, enable editing of your site in Visual Studio Online (under the Configure tab). This will enable a new option in your site's dashboard:

    2) On your dashboard, edit the project in VSO. The Sqlite database will be located under content\data\ghost.db.