Search code examples
nginxdigital-oceanghost

How to create a blog.domainname.com on digitalocean instead of the blog being hosted on the domainname.com


I'm hosting my blog on digital ocean and I want to set up a home page with a blog.domainame.com to access my blog, I must be googling the incorrect stuff as I cannot find any resources on this.

I'm using nginx to host my blog with Ghost on digitalocean, any help or guidance appreciated.


Solution

  • There are several steps but it's like create a duplicate website in fact.

    You will need to update your site configuration

    sudo touch /etc/nginx/sites-available/second-domain
    

    And create a symlink to this configuration

    sudo ln -s /etc/nginx/sites-available/second-domain /etc/nginx/sites-enabled/second-domain
    

    Next you must create a new folder in /var/www/, it will be the folder of your second domain. Update the config.js to match your second domain name and change the port.

    The last step is to create a new system service.

    vim /etc/systemd/system/secondsite.service
    

    This solution work with a custom installation of Ghost on Ubuntu.

    I write an article which combine all the information and more details if you want to serve several Ghost blogs in one droplet. You will find all the step from scratch in case you don't have the same configuration.

    Install multiple Ghost CMS on DigitalOcean