How To Deploy Ghost On OpenShift Manually

This is a quick guide on hosting your own Ghost blog specifically on OpenShift manually without any provided quickstarts.

  1. Installing Ghost
    After logging into your OpenShift machine, you will find yourself located at $OPENSHIFT_REPO_DIR. Install Ghost by following the guide from the original Ghost folks.

  2. Configuring Ghost
    This step is needed due to OpenShift's own environment variables. Changes should be done within config.js, which you can create by copying the provided config.example.js template when installing Ghost. Update the config.production.url and config.production.server as the following:

    {        
      url: process.env.OPENSHIFT_APP_DNS_ALIAS || process.env.OPENSIFT_APP_DNS || "localhost:2368",
     server: {
      host: process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1',
      port: process.env.OPENSHIFT_NODEJS_PORT || '2368'
    }
    
  3. Setting Up OpenShift's Action Hooks
    OpenShift provides entry points into application and platform lifecycle operations through which they call action hooks. This step is needed in order to create persistent GHOST_DIR/content/data/ and GHOST_DIR/content/images/ directories in case the machine has to be restarted. In order to setup the action hooks, copy over the files from OpenShift's Ghost Quickstart to .openshift/action_hooks/ within the app repo directory. Make sure the action hooks are executable by giving permissions through chmod +x.

  4. Running Ghost
    If you have any custom domain to use, be sure to set it up as an environment variable through export OPENSHIFT_APP_DNS_ALIAS=www.mydomain.com. After all is done, start running your blog on a separate tmux or screen session. Those not familiar with this may use the command nohup npm start --production > /dev/null 2>&1 & to run the blog.

Open Comments