/ raspberry pi

Optimise your Ghost blog for Raspberry Pi using NGINX

In our last post, we used Supervisor to run Ghost as a service on boot. We are now ready to optimise our Ghost blog using a HTTP server called NGINX.

Being a low resource, high performance and stable HTTP server (and open source), NGINX is an ideal solution to run on our Raspberry Pi Ghost server.

Installing NGINX

Luckily, Raspberry Pi users can install NGINX quickly and easily from the command line as it is available in the Raspbian default repositories. We'll run the following commands to get us up and running:

sudo apt-get install nginx
cd /etc/nginx/sites-available/
sudo nano ghost.conf

This will install NGINX, then we'll change to the install directory and then create a configuration file that will be used to serve our Ghost blog. You'll now need to add the following when Nano has opened, but replacing the {DOMAIN} with the domain name you own and want to use. In my case, this was simply ghostpi.pro, so just be sure to set this here:

server {

    listen 80;
    server_name {DOMAIN};

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;


This configuration file will direct our Ghost blog to the relevant server (your domain name) and use the default HTTP port 80, so visitors won't need to add :2368 at the end of the URL.

Again, exit (CTRL+X) and save (Y) and then run the following commands to link the configuration file to the right places:

sudo ln -s /etc/nginx/sites-available/ghost.conf /etc/nginx/sites-enabled/ghost.conf

All that's left is to restart NGINX by running:

sudo service nginx restart

Read more

If you are interested in gaining a better understanding of how you can maximise the benefits of NGINX, then take a look at Alex Ellis' blog which explores NGINX in greater detail.

Next steps

Now at this point, you may notice that you cannot access your Ghost blog any more. Don't panic! We need to make a few more changes to get this working, and it doesn't take long or much expertise. We'll cover this in the next post.

Wesley Archer

Wesley Archer

Digital Account Manager by day, and maker in his spare time. Also, a regular contributor to The MagPi Magazine for the Raspberry Pi Foundation.

Read More