Set up https for a subdomain

Posted November 10, 2021 79 views
ApacheDigitalOcean Droplets

Hi All,

I have a site which is a subdomain ( hosted on DigitalOcean while its parent ( is not. I am trying to set up https for this site using the DigitalOcean tutorial, but it asks me to set up a virtual host for the site. Does someone know how to do this for my site? Do I need to set up virtual host for parent domain ( as well? If not, how do I set up only the subdomain (

I tried contact DigitalOcean support, but they seem not understanding my problem.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi @tonglingdyq,

You only need to configure a virtual host for your subdomain. Basically, if you need HTTPS, then you need an SSL certificate on your subdomain. In order to use this SSL certificate, you’ll need to authenticate and so on. To do that, you need to have your domain accessible from the outside world and to do that, you need to configure your virtual host file.

With that in mind, DigitalOcean has a pretty good tutorial on how to achieve this:

I’ll recommend reading section 5 - Step 5 — Setting Up Virtual Hosts (Recommended)

Once done, you can continue with the SSL tutorial.

by Erin Glass
The Apache HTTP server is the most widely-used web server in the world. It provides many powerful features including dynamically loadable modules, robust media support, and extensive integration with other popular software. In this guide, we'll explain how to install an Apache web server on your Ubuntu 20.04 server.
  • Thanks, a quick question about the tutorial language. It mentions the folder name should be your_domain and in the configuration file, it also used this alias, as shown below:

    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName your_domain
        ServerAlias www.your_domain
        DocumentRoot /var/www/your_domain
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Since my subdomain is in the format of, how should I fill in those places?

    I can see using abc_def for the folder name, but I am not sure what to use in the configuration file, i.e. what to put in place for the following lines:

        ServerName your_domain
        ServerAlias www.your_domain
        DocumentRoot /var/www/your_domain
    • Hi @tonglingdyq.

      You should put the domain/subdomain you want to use. In your case, you need to put You can put as a name for your folder.

      • So something like this:

            DocumentRoot /var/www/abc_def


          • I tried this, but now when I use sudo apache2ctl configtest to check for error as in the tutorial, the following is the error returned:

            AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using Set the 'ServerName' directive globally to suppress this message

            I tried access my site in a browser, not it only shows the html file created in the step 5… I don’t have access to the original WordPress site anymore…

            Any help is much appreciated!!!

Hi @tonglingdyq,

I’m answering here as the comment section no longer allows replies.

The DocumentRoot /var/www/your_domain variable needs to be where your WordPress is. It can be in /var/www/html or somewhere else.

If you want your Wordpress to be in the /var/www/your_domain, you can just rename it like

cd /var/www
mv wordpressfolder abc_def