How To Host Ghost with Nginx on DigitalOcean

Published on September 24, 2013

Alex LaFroscia

How To Host Ghost with Nginx on DigitalOcean


In April 2013, John O’Nolan, no newcomer to the field of blog-making, launched a Kickstarter for a new kind of blog called Ghost, which could radically simplify writing and maintaining a blog. Here, we’ll walk through all of the steps to get Ghost set up and running on a DigitalOcean VPS.


Before you get started, there are a few things that you should pull together

  1. Obtain a copy of Ghost

    • This tutorial will assume you already have a copy of Ghost on your local computer. Since it’s only available to Kickstarter backers right now, you should have been sent a link to the site where you can download it. <br/>
  2. Set up a VPS

    • This tutorial will assume that you’ve already set up a VPS. We’ll be using Ubuntu 12.04, but you should be fine with whatever you’d like. If you need help with this part, this tutorial will get you started. <br/>
  3. Point a domain at your VPS

    • This tutorial will assume that you’ve already pointed a domain at your VPS. This tutorial should help you out with that part, if you’re unsure of how to do that.

Step 1: Install npm

Before we get started, I highly recommend making sure your system is up-to-date. Start by SSHing into your VPS by running:

ssh root@*your-server-ip*

on your local machine, and running the following on your VPS:

apt-get update
apt-get upgrade

Once that is complete, we need to get npm installed. Running the following commands will install some dependancies for Node, add its repository to apt-get, and then install nodejs.

apt-get install python-software-properties python g++ make
add-apt-repository ppa:chris-lea/node.js
apt-get update
apt-get install nodejs

Note: You shouldn’t need to run the commands with sudo because you’re probably logged in as root, but if you’re deviating from this tutorial and are logged in as another user, remember that you’ll probably need sudo.

Now, if you run npm at the command line, you should see some help information printed out. If that’s all good, you’re ready to install Ghost!

Step 2: Install Ghost

The next thing to do will be getting your copy of Ghost onto the remote server. Please note that this step is only necessary for now, while Ghost is in beta. Once it is available to the public, it will be installable through npm (and this tutorial will likely be updated to reflect that).

You’re welcome to download the file directly to your VPS or transfer it via FTP. I will show you how to use SCP to copy the folder from your host to the server. The following commands are to be run in your local terminal:

cd /path/to/unzipped/ghost/folder
scp -r ghost-0.3 root@*your-server-ip*:~/

This will copy all of the contents of the ghost-0.3 folder to the home folder of the root user on the server.

Now, back on the remote server, move into the Ghost folder that you just uploaded and use npm to install Ghost. The commands will look something like this:

cd ~/ghost-0.3
npm install --production

Once this finishes, run the following to make sure that the install worked properly:

npm start

Your output should look something like the following:

> ghost@0.3.0 start /root/ghost-0.3
> node index

Ghost is running...
Listening on
Url configured as: http://my-ghost-blog.com

If that is the case, congratulations! Ghost is up and running on your server. Stop the process with Control-C and move onto the next steps to complete the configuration.

Step 3: Install and Configure nginx

The next step is to install and configure nginx. Nginx (pronounced “engine-x”) is “a free, open-source, high-performance HTTP server and reverse proxy”. Basically, it will allow connections from the outside on port 80 to connect through to the port that Ghost is running on, so that people can see your blog.

Intallation is simple:

apt-get install nginx

Configuration is only a little more challenging. Start off by cding to nginx’s configuration files and removing the default file:

cd /etc/nginx/
rm sites-enabled/default

Now, make a new configuration file:

cd sites-available
touch ghost

And paste in the following code, modifying it to adapt to your own configuration (the only thing you should need to change is the domain name):

server {
    server_name *your-domain-name*;
    access_log /var/log/nginx/*your-domain-name*.log;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header HOST $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_redirect off;

Finally, create a symlink from the file in sites-available to sites-enabled:

cd ..
ln -s /etc/nginx/sites-available/ghost /etc/nginx/sites-enabled/ghost

This will listen for traffic incoming on port 80 and pass the requests along to Ghost, provided they are connecting to the domain that you provide.

Start up the server again (use the code from the end of Step 2) and visit your domain. If you see Ghost, you’re good to go!


Step 4: Configure Upstart

The last step is to make an Upstart task that will handle Ghost and make sure that, should your server get turned off for some reason, Ghost will get kicked back on. Start by making a new Upstart configuration file by doing the following:

cd /etc/init
nano ghost.conf

And paste in the following configuration:

# ghost

# description "An Upstart task to make sure that my Ghost server is always running"
# author "Your Name Here"

start on startup

    cd /root/ghost
    npm start
end script

This should ensure that Ghost gets started whenever your server does, and allow you to easily control Ghost using service ghost start, service ghost stop, and service ghost restart.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about us

About the authors
Default avatar
Alex LaFroscia


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

DigitalOcean Employee
DigitalOcean Employee badge
October 14, 2013

This comment has been deleted

    If anyone else is having issues installing an SSL via the official instructions here due to this error;

    Could not automatically find a matching server block for yourdomain.com. Set the `server_name` directive to use the Nginx installer.

    I was able to fix this by editing /etc/nginx/sites-available/<yourIP>.conf and changing the “server_name” to use my domain name (“mydomain.com”) instead of the IP address

    If anyone else is having issues installing an SSL via the official instructions here due to this error;

    Could not automatically find a matching server block for yourdomain.com. Set the `server_name` directive to use the Nginx installer.

    I was able to fix this by editing /etc/nginx/sites-available/<yourIP>.conf and changing the “server_name” to use my domain name (“mydomain.com”) instead of the IP address

    1. " server_name your-domain-name " Can I use an IP address?
    2. I would like to use www and no www prefix domain name, but now there is no " www " prefix effective," www " open is “Welcome to nginx!” ,How ti fix it ?

    Minor Correction

    $ ln -s /etc/nginx/sites-available/ghost sites-enabled/ghost

    So that: Location “/etc/nginx/sites-enabled” Links to “/etc/nginx/sites-available/ghost”

    $ ln -s sites-available/ghost sites-enabled/ghost Causes Location “/etc/nginx/sites-enabled” Links to “sites-available/ghost”

    This is a fantastic write-up!

    Just for the sake of completeness, I would like to bring your attention to this article that talks about multiple managed service providers for hosting a ghost blog at almost the same price. https://www.attosol.com/where-to-host-ghost/

    does the domain name need to be my fully qualified domain name?

    example if my Fully qualified domain name is CoolSite.com, but I want my blog to be accessed by CoolSite.com/Blog how would I go about that?

    Error in the article: symlinks will do the wrong thing if you make them relative. To make them absolute, simply prepend ~+/ to them. In most shells, ~+ evaluates to the current directory like ~ evaluates to your home directory. For example, ln -s ~+/sites-available/whatever ~+/sites-enabled/whatever

    For the latest version of Ghost (0.6.4) I believe the start command should be:

    npm start --production

    Can anyone else confirm this?

    is the root user required for this to work? All i get is the nginx welcome page and not the ghost blog… I currently use a sudo user i created from root… i am not sure why it is not working but i am guessing because I am not doing from the root user???

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    Join the Tech Talk
    Success! Thank you! Please check your email for further details.

    Please complete your information!

    Featured on Community

    Get our biweekly newsletter

    Sign up for Infrastructure as a Newsletter.

    Hollie's Hub for Good

    Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

    Become a contributor

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    Welcome to the developer cloud

    DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

    Learn more
    DigitalOcean Cloud Control Panel