How To Install Ghost In a Subdirectory

There are two main steps to install Ghost in a subdirectory. You need to update the Ghost config so it knows it is in a subdirectory, and then use apache or nginx to point the right traffic to Ghost

To tell Ghost where it should live, in the config.js file, just add your desired subdirectory name to the end of the production URL. For an example see the following screenshot:

Ghost Config

With that example, your Ghost blog would be reachable at Now you just need to configure your web server to proxy requests that are for to Ghost.

Ghost Subdirectory with Nginx

To have Nginx proxy requests for our /blog/ subdirectory, we need to make a configuration change to the Nginx conf file. For most setups, this config file is located in /etc/nginx/sites-enabled/. We will be adding onto what already exists in your configuration file.

Since we want to proxy all traffic from /blog to Ghost, we set that as the location and proxy traffic to port 2368. Here is what that looks like:

server {
    listen       80;
    server_name  localhost;

    location ^~ /blog {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_redirect off;

Once you have added that to the configuration file, you can restart Nginx with sudo service nginx restart. Now, if you make a request to your base URL, Nginx will serve the default website, but if you added on /blog/ to your URL, you will be served your Ghost blog. How To Install Ghost In a Subdirectory - Nginx Conf File

Ghost Subdirectory with Apache

Similar to Nginx, to make Ghost and Apache work together we need to edit the Apache conf file. This is typically located at /etc/httpd/conf/httpd.conf.

Here is what you want to add on:

<IfModule mod_proxy.c>
      ProxyPreserveHost On
      ProxyPass /blog/
      ProxyPassReverse /blog/

How To Install Ghost In a Subdirectory - Apache Conf File

Restart apache with apachectl graceful.

With that conf snippet in place, Apache will serve as the site you already have setup and requests for will be proxied to which is Ghost running on port 2368. If you run into any trouble or have any questions, feel free to comment below.