Settings up Ghost

The guys at work were talking about how they set their blogs up using ghost. At first I didn't really like the idea of using something other than Drupal to run a website but was suprised. It wasn't until another friend was looking to set up a blog that I decided to set it up for her and through that decided to use it myself. This is my experience setting it up.

Getting it ready

On your server you will download ghost to a directory you want it to run from.

cd /var/www/
curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip
unzip -uo ghost.zip -d ghost
cd ghost

In this directory you shoudl see the following folder structure. Except for the node_modules folder. This comes in the next step.

Now we will need to install Ghost.

npm install --production

This will take a little bit as it downloads all the peices. At this point we can run Ghost using:

npm start

Your blog should be avaliable at http://127.0.0.1:2368

To create your admin user go to http://127.0.0.1:2368/ghost

Ghost on Apache with mod_proxy

Yeah it's true my server wasn't all node.js worthy and I was previously running apache. Because of this I had to figure out a way to get apache to pass this to the node.js server that is running Ghost. First I enabled two apache modules.

sudo a2enmod proxy proxy_http

Onces those are enabled we need to create a new virtual host for apache.

cd /etc/apache2/sites-available/
touch example.ca
nano example.ca

And then use the following to set up a new vhost for /var/www/ghost/ where the ghost project files are.

<VirtualHost *:80>
ServerAdmin admin@example.ca
ServerName example.ca
ServerAlias www.example.ca example.ca
DocumentRoot /var/www/ghost
 
ProxyRequests off
ProxyPass / http://127.0.0.1:2368/
ProxyPassReverse / http://127.0.0.1:2368/
ProxyPreserveHost On
 
<Proxy *>
Order deny,allow
Allow from 127.0.0.1
</Proxy>
 
</VirtualHost>

Then to enable the vhost and restart apache.

sudo a2ensite example.ca
sudo /etc/init.d/apache2 reload

At this point apache is now set up to forward all requests for www.example.ca to the node.js server running the Ghost instance.

Ghost Forever and ever and ever...

By now I was noticing that I would require a daemon of some sort to keep Ghost running as a service. At first I looked in to setting it up using a init.d script but realized I had no clue what I was doing. And for ease of use and clairty of the install directions I found forever.

npm install forever -g

Forever needs to be installed globally so the above command uses the -g flag. Now we navigate to the project folder. and run:

forever start index.js

Your server should be up and running. To stop your server:

forever stop index.js

More advanced setting I choose with this blog was to set it up with some output logs.

forever -o ../out.log -e ../err.log -l ../forever.log start index.js

Settings I didn't set up but probably will after writing this would be to set up --minUptime and --spinSleepTime just to have a bit more control over the instance.

If you type forever list you should be able to see forever monitoring your script as daemon running.