Multiple blogs on the same domain

Hi All,

Coming from wordpress to ghost is quite refreshing. I’m new here and haven’t setup any working ghost site yet.

I have read using ghost as an npm module
https://docs.ghost.org/v1.0.0/docs/using-ghost-as-an-npm-module
and I’m wondering whether it is possible to create multiple blogs in different sub directories e.g. domainname.com/blog and domainname.com/blog2. Is it possible to do something like the following.

ghost().then(function (ghostServer) {
    parentApp.use('/blog', ghostServer.rootApp);
    ghostServer.start(parentApp);
});

ghost().then(function (ghostServer) {
    parentApp.use('/blog2', ghostServer.rootApp);
    ghostServer.start(parentApp);
});

Thank you in advance.
Anurat,

1 Like

Using Ghost as an npm module isn’t really recommended, is there a reason you want to take that approach?

The recommended approach would be to install two ghost instances and when prompted specify the url with the subdirectory, you can then configure the subdirectory proxies as part of your parent app’s web server config.

Thank you Kevin,

I’m trying to find a way to create multiple blogs in one website and I didn’t know that using Ghost as an npm module isn’t recommended. I’m fine with installing two ghost instances.

Could you elaborate more on how to install two ghost instances? Should I create a new directory for each ghost instance e.g. /blog for the first ghost instance and /blog2 for the second ghost instance?

Also when you say “configure the subdirectory proxies as part of your parent app’s web server config”, do you mean configure nginx to redirect the http request to the corresponding ghost instance?

Best Regards,
Anurat,

Exactly! :smile: Create a directory for the first blog and run ghost install inside of it, then create a directory for the second blog and run ghost install inside of that.

Yes, configure nginx but to proxy rather than redirect. Eg, adapting Ghost-CLI’s default nginx template:

    location /blog1 {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;
        proxy_redirect off;
    }

    location /blog2 {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2369;
        proxy_redirect off;
    }

Replacing the locations and 2368/2369 ports to correspond with your desired sub-directories and the ports that were set up for you when installing the respective ghost instances.

5 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.