When I started this blog, I forgot to configure the
www. prefix. Damn it! There were so many steps to meticulously follow to get the blog going, and I was a little afraid to do anything to modify the configuration.
When I wanted to go add the new domain, there were a few steps. It took scouring around the internet, but I eventually found how.
The same general rules apply to adding new domains (e.g. if you want to change the domain name of your blog).
These rules apply if you self-host using DigitalOcean. But it's not terribly easy, and involves editing your core site code.
A much easier way to host your Ghost blog and manage it all is to let them do the heavy lifting for you. It's $29 a month and you get a ton of benefits, and zero random crashes and downtime.
Step 1: Point the domain at your new IP address
Do this with your domain admin. In my case, it was in Hover, but it would work with NameCheap, Godaddy, or one of the dozens of others.
I added one line, an A reference:
Step 2: Modify your NGINX configuration
I use NGINX as a web server (for Ghost). For most out-of-the-box servers, NGINX is the default (I've never heard of someone using Apache with Ghost).
/var/etc/sites-available. You need to modify two files:
In both of these, you need to add in the new domain or the
www. prefix into the configuration. Open up one of the files:
sudo vim /var/etc/sites-available/your-site.net-ssl.conf
In it you'll find the server block (it's the only thing in the file, it's right up top), where you add the www prefix (added in the image below, right after 'hooshmand.net')
sudo service nginx restart
To be honest — I'm not sure if it's necessary to restart Ghost, but I did it and it was painless.
In your ghost folder:
Step 3: Create/add certificates for your new domains
After you've modified
nginx, you need to add certificates for your new domain. You actually are going to add the www subdomain to the existing certificate.
To do this, you use
sudo certbot -d hooshmand.net -d www.hooshmand.net
certbot is called
letsencrypt on some installations.
Certbot will ask you some questions. The answers are:
- When it asks you something like 'There is an existing certificate. Do you want to add the new domain to the existing one?' you say 'yes'.
- When it asks you something like 'Do you want to redirect non-https traffic to https traffic?' also say you want to.