In the above file, we are going to add below lines.
ServerName subdomain.vlemonn.in ServerAlias www.subdomain.vlemonn.in ServerAdmin webmaster@vlemonn.in DocumentRoot /var/www/subdomain.vlemonn.in/html
Now we need to create subdomain.vlemonn.in/html folder in /var/www/ folder. Execute below commands line by line to create directory
cd /var/www/ sudo mkdir subdomain.vlemonn.in sudo mkdir html
Now our folder is ready. Let’s create an index.html file to handle HTTP request. Execute below command to open nano editor.
sudo nano index.html
In nano editor add a welcome text “Hello vLemonn!”. Ignore HTML for the time being. Save the file by pressing Ctrl+O followed by Ctrl+X.
Now it enables configuration and then restarts the server. Execute below command line by line.
sudo a2ensite subdomain.vlemonn.in sudo service apache2 restart
Finally, our server is ready to handle HTTP request. What next? Now we need a DNS entries to handle subdomain request. For this follow below steps for cloud.google.com console page.
For creating DNS records or entries we need to open Network Services -> Cloud DNS under NETWORKING section in the left menu.

Add a recordset.
DNS name : subdomain.vlemonn.in
Record Type: A
IPv4: <Server IP>
Don’t modify any other fields. Click on Create button to save the changes.
Create another record set to handle www requests for our subdomain
DNS name : www.subdomain.vlemonn.in
Record Type: A
IPv4: <Server IP>
Don’t modify any other fields. Click on Create button to save the changes.
Let’s try to visit our new subdomain “subdomain.vlemonn.in”. If everything is fine you are able to check our page.
You may also like below articles.
- Compute Engine Create First VM Instance
- How to Install phpMyAdmin?
- How to add SSL?
- How to add Files?
- How to configure FileZilla?
- How to download Google Cloud SDK?
- How to create a subdomain?
- How to add another domain?
Finally, check this video for all above steps
In our previous article on Google Cloud Platform we covered below points
- Compute Engine Create First VM Instance
- How to Install phpMyAdmin?
- How to add SSL?
- How to add Files?
- How to configure FileZilla?
- How to download Google Cloud SDK?
- How to create sub domain?
- How to add another domain?
In this article we are going to learn about How to add a Sub Domain. Before start we are assuming, you already have a working Compute Engine VM Instance. In this article we are going to use Ubuntu 17.10. If you are looking for any other OS. Please refer below articles.
For creating a subdomain in Ubuntu 17.10 follow below steps.
Let’s first modify our server to handle request for new sub domain. Open terminal and navigate to “/etc/apache2/sites-available/”. Execute below command in terminal
cd /etc/apache2/sites-available/
In this directory we have default conf file 000-default.conf we are using it as a base for our new sub domains. Execute below command to create a Copy of 000-default.conf file.
sudo cp 000-default.conf subdomain.vlemonn.in.conf
Now it’s time to edit newly created file in nano editor
sudo nano subdomain.vlemonn.in.conf
Below image show the default file structure. We are going to modify highlighted lines.


