Deploy Ghost Blog to a subdirectory using Nignx on Ubuntu Server

I am sharing how I deployed ghost onto my server with a differeent subdirectory.

STEP 1: Install Node.js

If you already have Node.js installed you can skip this part.

STEP 2: Install Ghost

Here I opened the directory where the source code for my site lies and install ghost using npm.

Step 3: Configure Ghost

To begin I copied over the example config file and then edited it.

Under the production section of the config file.

  • I Changed the default url to include your subdirectory
  • I Changed the host
  • I Changed the mailer. To continue this part, I had to go over to Mandrill and sign up for an account. Mandrill will be used to send mail for the blog.

Step 4: Create ghost User

Here I created a new user and run the test to see that Ghost is running.

If you see the message "Ghost is running." you have successfully installed ghost. Press CTRL+C to exit the process.

Step 5: Run ghost as background process

I now have ghost running but I need to keep the terminal open to have it run. My goal is to have it run in the background, and I will use forever to acheive this. Forever is a CLI tool for ensuring that a given script runs continously. You can look up the documentation here.
Install forever and start a process with the index.js file.
Run this code from within the ghost directory

Step 6 : Nginx configuration

I had to find the Nginx config file and edit it to set the /blog to proxy to the port that ghost sits on; default : 2368.

If you cannot find your nginx config file, checkout the nginx documentation for other possible locations.

After I found the file, I edited the file like this

Next. restarted Nginx and my blog was live.
sudo /etc/init.d/nginx/ restart or service nginx restart

Now when you go to yoursite.com/blog you should have your ghost blog there.