Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Sign In

Login to our W3Make Forum to ask questions answer people’s questions & connect with other people.

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Create Subdomain on DigitalOcean & configure Apache Virtual Hosts

Create Subdomain on DigitalOcean & configure Apache Virtual Hosts

This post is to demonstrate how to create subdomain on DigitalOcean droplet (VPS) in a few simple steps.

Step 1: Create a new A record

Go to networking section.

Create a new A Record with hostname being ex. demo or test. Where redirect to is the IP address i.e. basically the IP address of the droplet or choose a droplet.

Step 2: Create sub directory & host project files

Create a directory under /var/www/ directory using the commands in putty (optional)

cd /var/www/

mkdir subdomain_folder_name

cd subdomain_folder_name

sudo nano index.html

When you are inside the index.html file, write anything ex. hello world.

`Hello World`

Step 3: Configure Virtual Host

Now let’s configure the apche2 virtual host, which will allow our domains to refer to a project directory.

Type in the following commands

cd /etc/apache2/sites-available/
cp 000-default.conf subdomain.website.conf
nano subdomain.website.conf

Now once you are inside the config file, change the following

#ServerName
#ServerAlias
#DocumentRoot

Here, the ServerName is basically the domain that you want – say demo.w3make.comServerAlias is basically another name using which you want to refer this domain any CNAME in most case. DocumentRoot is where your project files are located (Root directory of your project)

Point DocumentRoot to the directory where your project files are located.

ex. DocumentRoot /var/www/subdomain_folder_name

ServerName demo.w3make.com

ServerAlias www.demo.w3make.com

Save the file and restart the server

sudo service apache2 restart

Now try to access your subdomain

https://demo.w3make.com

Related Posts

1 Comment

Leave a comment

You must login to add a new comment.