Set up https for a subdomain

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.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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

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.