How to Add a Sub-Domain in Virtualmin

A client on ListingDock asked me to write this tutorial for them. I haven’t posted anything related to Virtualmin in a while. I haven’t had the time. A big thank goes to dap7 for financing this tutorial. So let’s see how to add a sub-domain in Virtualmin.

Before you add a sub-domain in Virtualmin, you need to create it within the domain’s DNS. In this case, DNS was managed by DigitalOcean. Refer to my Adding a Sub Domain with DigialOcean DNS tutorial if you haven’t done this already.

Once you have the sub domain pointing to your droplet, you can move on to Virtualmin part of sub domain creations…

Adding a Sub-domain in Virtualmin

Adding a sub-domain is similar to adding a new domain to your Virtualmin. But instead of creating a new server, you should create a sub-server for your sub-domain. Although creating a top-level server will also work, going with sub-server help you organize your server. So let’s create a sub-server.

screencapture-sr-watismanagement-com-10000-1452227270628Login to Virtualmin with your root password and select the domain you’re adding the sub-domain from left sidebar. You don’t have to worry about that if you only have one domain on your server. It will be selected by default.

Under the domain name drop-down, you’ll find a link with the text Create Virtual Server. Click it and you’ll be taken to a page where you can create a new server. Top-level server will be selected as the server type, click Sub-server from the top menu to change it to sub-server.

Now type the sub-domain you created in DigitalOcean on the Domain name field. You can type anything you want in the Description field. Don’t change anything else and click Create Server button.
screencapture-sr-watismanagement-com-10000-1452228133185

New sub-server will be created within few seconds. Once it’s done, you’ll be given a link to view details of the server you just created on the bottom of the page.

Where to upload website files?
On the page that contain your new server details, you can see admin username for the sub-domain, which will be same as the root domain. And you’ll see home directory for the sub-domain, which will be in following format.

/home/AdministrativeUsername/domains/sub.domain.com

If you go to this directory with a FTP client, you’ll see a directory named public_html inside it. This is where you should upload your website files. Meaning the web-root for your sub-domain will look like this,

/home/AdministrativeUsername/domains/sub.domain.com/public_html

And remember to use your Administrative Username to upload files. Uploading as root will cause permission errors on your website.

You can find MySQL database and password for the server by clicking Edit Databases from the left sidebar. Your sub-domain should be configured properly now. You can now connect to your server with FTP client and upload your website.

Tharindu

Hey!! I'm Tharindu. I'm from Sri Lanka. I'm a part time freelancer and this is my blog where I write about everything I think might be useful to readers. If you read a tutorial here and want to hire me, contact me here.

Related Articles

9 Comments

  1. Hey thanks for this walkthrough. I’m reaching out cause I’ve had no luck finding answers. I have a domain. xyz.com and I followed your steps to make test.xyz.com. I can access test.xyz.com from inside my network but not from outside. How do I get that part working? Thanks!

  2. Hi Tharindu,
    I´m a customer yours and I have a problem: when I sign in in my virtualmin admin panel I have not the option “Create Virtual server”. I looked it but I don´t have in my admin panel.

    Please help me.

    Regards.

      1. Thanks for your answer mate.

        I think that I´m using root account you give me the datas but I think that I have not access to root account.
        You can see the datas I have:
        https://www.screencast.com/t/7uWVRgeyHFN

        Also I see I have a update to phpMyAdmin and I can´t update it say me that I don´t allowed to edit this virtual server:
        https://www.screencast.com/t/gsfPrPiG

        Also I see that have only one user in my virtualmin.

        Also I see “Administration Username”: the username I use.

        Enable features:
        https://www.screencast.com/t/h7xLdSQL

        Thanks a lot for your help mate.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button