There are quite a few good tutorials for installing ghost on various platforms but no single solution worked for everything that I wanted and I ended up with a dozen or so windows open in my browser. So I decided to write up the steps I used to hopefully save someone some time Googling.

If all you want is somewhere to write down your thoughts then I would definitely recommend using a one-click installation available from several hosting providers such as Digital Ocean or Rackspace. This can get you up and running in a matter of minutes.

If you want more customization such as having a full website with Ghost integrated as the blogging platform or you like doing things your own way, then you can try following the steps below.

Overview

Basically my setup is as follows:

  • Hosted on Digital Ocean
  • Domain name from NameCheap.com
  • Personal PC is running windows 7
  • Web server running Ubuntu 12.04.3 x32 OS

Getting Started

First thing to do is sign up for an account at Digital Ocean.
Registration is free and you only pay for what you use. If things go smoothly you should be able to have the blog up and running and it will only have cost you $0.007.

Setting up your Server

DigitalOcean has a simple tutorial for setting up your first droplet (ie. server) available here.

For the setup choose:

  • Enter a name for your droplet (server for example).
  • Select Size: 512MB RAM/1 CPU)
  • Select Region: closest location to you
  • Select Image: Ubuntu 12.04.3 x32
  • Leave everything else alone.

Click create and after about 60 seconds you should have your first droplet created. You will receive an email which will have the IP Address, username and password to the Droplet.

Basic Setup for your Server

Now that you can access your droplet we can do the basic setup for the server and enable some security options for the server.

If you are logged in from putty, you have already completed step one in the basic server setup.

Installing Nginx, MySQL and PHP

These tools are necessary/useful if you want to host your own website and want to have your blog on a subdomain (ie. blog.latitude51.ca)

You can follow the tutorial here to install the applications.

Once you have gotten to this point you should be able:

  • to see the Nginx server by entering your server's IP address into your web browser
  • to see php info page by entering your server's ip-address/php.info

Setting up your Domain Name

Using your IP address as your website domain is not a very good option. So instead we want to point a domain name to the IP address of your server. I got my domain name from NameCheap.com. They have a good price and they also have free whois blocking so that when someone performs a whois search for your site, your whole life story isn't visible.

To setup the domain you can follow step 4 from Ghosted.co.

Once you have created the domain we can add in several CNAME records. CNAMES are used to allow for sub-domains such as blog. or www. to be used. Also, if the user makes a mistake in entering the url it can still direct the user to the correct page.

After clicking "Create Domain" you should now be at your DNS management page:

DNS management page

Click Add Record and click CNAME.
Enter a new CNAME

For Enter Name type www and for Enter Host Name type @. Then click Create.

The CNAME record should now be visible in the list:
CNAME record added

Now add two more CNAME records, blog and *, using the same approach as above. This will allow us to use a subdomain similar to the one I use for my blog.

Unfortunately, this step requires some time for everything to get updated properly. I think it was 6+ hours for me. So at this point it may be a good time to take a break!

Once the changes take affect you should be able to type your domain name into your browser and "Welcome to Nginx!" page should be visible. Eventually, this will be the location of your website and we will redirect users who type blog.yourdomainname.com to your Ghost blog.

Installing NODE.js

The Ghost blogging platform runs on Node.js. So it is necessary to install this on your server. Open up your putty connection if it was closed. Once it is up and running. Assuming you are logged in as a user, and not as root we need to put sudo in front of all of the commands.

First, we should update the Ubuntu repository. At the command prompt type:

sudo apt-get update

Next, install some tools required to make the process work smoothly.

sudo apt-get install build-essentials -y

sudo apt-get curl -y

sudo apt-get install git -y

sudo apt-get install python libssl-dev -y

Now we can install Node.js from the sources. In my case I used v0.10.24, but you can check what the latest version here.

cd /usr/src/
wget http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz
tar -xzvf node-v0.10.24.tar.gz
cd node-v0.10.24
./configure
make
make install

The last few steps will require several minutes to perform. To confirm that everything was install properly type
node -v in the command prompt which will output the version of node.js that was installed.

Installing Ghost

First, confirm that unzip has been installed on your server. Type:

sudo apt-get install unzip -y

Next, check what the latest version of ghost is here. I was using v0.3.3.

To install Ghost:

cd /usr/share/nginx/www
sudo mkdir ghost
wget https://ghost.org/zip/ghost-0.3.3.zip
unzip -uo ghost.zip -d ghost
cd ghost

To check that everything unzipped properly type ls in the command prompt and the following should be diplayed (where demo is the username and myserver is the server name):

demo@myserver:/usr/share/nginx/www/ghost$ ls
CHANGELOG.md       content       index.js      package.json
config.example.js  core          LICENSE.txt   README.md
config.js          Gruntfile.js  node_modules

To confirm that everything install properly, type:

npm install --production
npm start

You should now see something similar to:

ghost@0.3.3 start C:\Users\Landon\Downloads\ghost-0.3.3
node index
Ghost is running...
Listening on 127.0.0.1:2368
Url configured as: http://my-ghost-blog.com
Ctrl+C to shut down

Press Ctrl+C to kill this process as it is no use to us.

Preparing Ghost for Production

In order make Ghost run in the wild we need to make Ghost re-start in the event of a system reboot or in the event of a crash. The Ghost blog has a good description for how to do this here under the Init Script section.

The lovely people at Ghost already did the hard work for us (ie. making the init script). To use their copy we can type:

cd /etc/init.d
wget https://raw.github.com/TryGhost/Ghost-Config/master/init.d/ghost

We need to modify the init script to make it work with our own domain. At the command prompt type:

sudo nano ghost

ChangeGHOST_ROOT=/var/www/ghost to GHOST_ROOT=/usr/share/nginx/www/ghost. Now save changes by pressing Ctrl+X then y then Enter.

Next, check the location of the daemon by typeing which node. Make note of the path, for me it is /usr/local/bin/node. Type:

sudo nano ghost

and change DAEMON=/usr/bin/node to the path that was displayed on the screen by the command which node. For me this looks like DAEMON=/usr/local/bin/node.

Save changes to the file.

Finally, we can setup a Ghost user to control the init script. We also have to ensure that the users have access:

sudo useradd -r ghost -U
sudo chown -R ghost:ghost /usr/share/nginx/www/ghost
sudo chmod 755 /etc/init.d/ghost

To check that all went well type:

sudo service ghost start
sudo service ghost status

and

 * ghost is running 

should be the output. Next, register the init scripts:

sudo update-rc.d ghost defaults
sudo update-rc.d ghost enable

Modifying Ghost Config.js

Edit the Ghost config file to point to your domain.

cd /usr/share/nginx/www/ghost
sudo nano config.js

Find all occurrences of http://my-ghost-blog.com with your domain. In my case it would be http://blog.latitude51.ca. Once complete press Ctrl+x, then y, then Enter to save the changes.

Modify Nginx Default Config File to work with your domain

Finally, we need to configure Nginx point to your domain and pass any request for blog.your-domain on to your ghost blog. To do this:

cd /etc/nginx/sites-available
sudo nano default

Scroll down to the end of the default config file. Then enter:

server {
    listen 80;
    server_name blog.your-domain.com;

    location / {
        proxy_pass http://127.0.0.1:2368/;
        proxy_set_header Host $host;
        proxy_buffering off;
        }
    }

Now save the file using Ctrl+x, y and Enter. This will automatically be updated in the file /etc/nginx/sites-enabled/default as well.

Now restart Nginx:

sudo service restart nginx

On your PC, open a browser and go to http://blog.your-domain.com, replacing your-domain.com with your sites domain name.

Your ghost blog should now be up and running!

Conclusion

You should now be able to view your ghost blog using the url above and your admin account using: http://blog.your-domain.com/ghost

You can now customize your ghost theme, input your specific information and write your first blog post!