Gregg Ink

Random Rants #1: Why I don't like adding subdomains to my website.

Step 1 You need to add a new configuration file: /etc/apache2/sites-available/foo.example.com.conf
(The specifics may vary depending on which linux distro you use, the version of Apache or the day of the week)

This isn't the worst part as it usually involves copying an existing file and making a few changes. This part even makes some sense. Part of me thinks that maybe it would have been simpler to put all subdomains in the same file. The other part of me thinks that the designers maybe knew what they were doing.

Step 2 A new DNS record in the DNS server.

This step too is fair enough and so far everything is within the realm of what is understandable. You really need to add two records: one for IPv4 and one for IPv6. That too, I can understand. All those DNS servers out there need to talk to each other and exchange notes such that your subdomain can be found anywhere in the world. This can take anywhere from a few minutes on a lucky day and up to 72 hours if you are having three consecutive bad days. I have never been that unlucky yet but I read on the internet that it can take that long and the internet wouldn't lie about that.

This is the point which can cause the most frustration. When your subdomain doesn't show up in a browser, how long do you wait before you decide it isn't working and you need to troubleshoot? When I was a beginner, that moment was straight away. When I finally realized that it normally takes a while, I started thinking how much I should put things back the way they were.

Anyways, you live and learn and today adding a subdomain is something you do in between doing something else just so you don't go insane. What could I do in the mean time? What about taking notes of everything I did and put it later on the internet so I have it for future reference? That will work.

So step 3: reloading Apache ... No wait! Nearly got me there. My friend, reloading Apache and be done with it would have been the next logical step. In a perfect world that would have been it, but we live in this one. Instead...

Step 3 Run totally arbitrary command "a2ensite foo.example.com"

I shall make no comment on how many times I got caught on that.

I can only imagine the designer thinking to himself: "How shall we make stackoverflow more popular? ... Oh, I know, we shall introduce a completely arbitrary command which will basically mean that this configuration file you just wrote for a new subdomain, you were serious about that."

I know some people will object and say that there is a reason for this command. I am sure the reason even sounds very clever. What it really does is create a symlink from /etc/apache2/sites-available to /etc/apache2/sites-enabled. I cannot understand why a2ensite needs 600 lines of perl to do that.

Step 4 Run command "service apache2 reload"

That last step I can agree with.

Tip

There is a small trick you can use so you don't need to wait for the DNS information to propagate. On your client machine you edit /etc/hosts and add the following line:

xxx.xxx.xxx.xxx     foo.example.com

This will allow your browser to find the subdomain immediately if it works properly. There is a small risk that you forget to delete that line afterwards and never realize your subdomain is really not visible to the rest of the world.

In conclusion

I have just added a new subdomain to my website (randomrants.greggink.com). I finally got around to making notes on how to do that. I have done it so many times by now, I don't really need them anymore.

Other things you might like: Factual Information about Bitcoin

  /u/gregg_ink
@Gregg_Ink

© 2024 Gregg Ink