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:

With that example, your Ghost blog would be reachable at http://your-url.com/blog/. Now you just need to configure your web server to proxy requests that are for http://your-url.com/blog/ 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:

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.

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.

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