Installing Ghost CMS on your mediatemple DV

February 5, 2014

In all of my excitement to get started playing around with Ghost I failed to realize the server understanding needed to get it properly installed and setup. I am not saying that Ghost is terribly difficult to install and setup, but what I found out is that unless things go perfectly with the tutorial you use you could find yourself stuck.

That’s what happened to me, and this article is meant for those wanting to install Node.js and Ghost on a Media Temple DV server.

What is Ghost?

Chances are if you are reading this article you know what Ghost is, but in case you don’t here is a brief explanation.

Just Blogging

Ghost is a CMS that was built out of the need for a simpler way to…well simply blog. WordPress is great, but can be a little much sometimes if you want to just write. Ghost solves that with a very simple backend that allows you to write using Markdown and easily publish your ideas to the web.

You can learn more about Ghost at www.ghost.org.

Installing Ghost

Specifically we are going to look at installing and setting up Ghost on a Media Temple DV level 4 server running Plesk (v11.0.9) and nginx. I first have to give a huge thanks to Fabian B @barajasfab for helping me get this working and writing the original how-to which you should check out as well. I have taken his instructions and made some adjustments based on mediatemple’s DV setup.

First things first – Let’s install Node.js

Ghost runs on Node.js and by default your server will not come with Node installed.

  1. Connect to your server via SSH as the root user
  2. Download this script that will help you install Node.js
    wget -O master.zip https://github.com/barajasfab/installframework/archive/master.zip
  3. Now let’s unzip it, make the script executable, and of course run the script itself
    unzip master.zip
    cd installframework-master/
    chmod 700 installframework.sh
    ./installframework.sh
  4. At this point you can follow the prompt and install Node.js.

NOTE: You will be prompted after Node.js has been installed to install Ghost. DO NOT install Ghost at this point.

Add your domain to Plesk & check some settings

We need to step out of the command line for a sec and head into Plesk.

  1. We first need to add our domain/sub-domain to Plesk. If you need a refresher on how to do that you can check out the Media Temple support article.
  2. Once you have added your domain in Plesk we need to do one more thing and check a couple of settings in Plesk. In Plesk click on Tools & Settings in the sidebar navigation. Next click on Apache Modules and make sure that proxy, proxy_http, and rewrite are checked. If not check them and click OK.

Installing & Configuring Ghost

Now for the main event…installing and configuring Ghost CMS. You will need to be back in the command line for these steps.

  1. We need to configure this new domain that we just added to Plesk
    cat << _EOF_ > /var/www/vhosts/<your-domain.com>/conf/vhost.conf
    ProxyPass / http://localhost:8000/
    ProxyPassReverse / http://localhost:8000/
    _EOF_

    If you get a No such file or directory error then run the command below and then repeat step #1.

    touch /var/www/vhost/<your-domain.com>/conf/vhost.conf
  2. Change directories and install Ghost
    cd /var/www/vhosts/<your-domain.com>/httpdocs/
    curl -L https://ghost.org/zip/ghost-latest.zip -o latest.zip && unzip latest.zip
    rm -f $_
    cp config.example.js config.js
  3. Now that we have Ghost installed we need to configure it for our domain. You can chose to edit this file in the shell by running the command nano config.js, or if you feel more comfortable you could FTP into your server and edit the file in your text editor.You need to edit url, host, and port in the Production section of config.js.
    url = http://<your-domain.com>
    host = 127.0.0.1
    port = 8000
  4. Now we finish installing Ghost by running
    npm install --production

Making Ghost easier to work with

There are a couple of things we want to do to make sure that Ghost runs forever, and we also want to give ourselves an easy way to start and stop Ghost.

  1. To make sure that Ghost is always running let’s install forever
    npm -g install forever
  2. Next let’s create the script to start Ghost
    cat << _EOF_ > ghostStart.sh
    #!/bin/bash
    NODE_ENV=production forever start index.js
    _EOF_
  3. And the script that will let us stop Ghost
    cat << _EOF_ > ghostStop.sh
    #!/bin/bash
    forever stop index.js
    _EOF_
  4. Make the scripts executable for yourself
    chmod 750 ghostSt*
  5. Now start Ghost by running the start script
    ./ghostStart.sh
  6. The last thing we need to do is reconfigure Apache and restart it.
    web
    /etc/init.d/httpd restart

    If the alis `web` is not setup run the command below

    /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain <your-domain.com>
    /etc/init.d/httpd restart

Ghost is now Installed and configured

Congrats, you did it! Your next step is to visit http://<your-domain.com>/ghost and enter in your details to set yourself up as an admin.

Again, a big thank you to Fabian B @barajasfab for doing most of the leg work on this.