05
Jan
2015

Creating subdomains with Webmin 1.7

A “domain” allows a URL to be assigned to a specific IP address (like google.com to 74.125.224.72). Obviously, its much easier to type “google.com” than “74.125.224.72”. These assignments are managed by DNS servers, which are specifically designed to act as “address books” to translate “google.com” to “74.125.224.72”, which then allows your computer to access the website.

A “subdomain” is used for managing multiple sites on one IP address (like www.example.com or support.example.com or about.example.com). This can be very useful for running multiple dedicated servers for these different sites (if you have more than one IP address) or running sites on the same IP address with totally different settings (eg, for administrative purposes).

In this guide, I will demonstrate how one sets up multiple subdomains under the Apache webserver, using Webmin as the configuration tool:

Screenshot - 050115 - 16:56:07

Here, we have a basic Apache installation with one subdomain, which handles all requests to www.thedevilonholiday.co.uk. When you created your DNS entry, where you assigned your IP address to your Domain name, you had something looking like this:

Screenshot - 050115 - 17:00:17

I am using CloudFlare, which reduces load on your server by handling some of the requests for you. As you can see, I have a top-level domain and the “www” portion, both resolving to the same IP address. This is great if you only have one website, and no other pages that could be used for administrative purposes. If you had another IP address (E.g. if you owned a range of addresses), you could assign another subdomain to that.

If you are a typical home user, you only have 1 assigned IP address, so you must run all your services from that. Webmin makes it easy to assign subdomains to their own web spaces by using Virtual Hosts. To create another local subdomain on your web server, you first need to create another DNS entry that maps to the same IP as before:

Screenshot - 050115 - 17:13:53

As you can see, I’ve disabled CloudFlare for this subdomain (maybe you want direct access). Next, click the “Create Virtual Host” tab in Webmin:

Screenshot - 050115 - 17:07:27

This is where it gets a little bit confusing: leave “Any Address” set and leave the port set to “Default“. Set your Document root to where your subdomain files will be (for example, /var/www/admin) and change your Server Name to the URL of your subdomain (E.g. admin.thedevilonholiday.co.uk):

Screenshot - 050115 - 17:12:04

Select Create Now, and then Apply Changes (at the top right) to save the configuration and restart Apache with the new settings. Now, you can create another website under admin.yourdomain.co.uk, with entirely different directives and files under /var/www/admin or whatever directory you chose (remember to correct the permissions otherwise you’ll get a 403: Forbidden error).

Screenshot - 050115 - 17:19:00

Just configure it like any other website and you’ll be able to access it from your new subdomain! Happy subdomaining!

Tip for SSH:Use screen to keep sessions running
A caveat of iOS 7

{2 Responses to “Creating subdomains with Webmin 1.7”}

  1. Holy shit. Thank you so much for doing this. It’s such a simple thing but other people complicate it like hell! Thanks!!!!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.