1

I am using AWS for the first time. I have created an ec2 instance and installed Apache server , made domain mapping from GoDaddy,

Now I want to create subdomains and point subdomains to the another document roots.

Like this :

www.mydomain.com should have domain root html\mydomain

www.test.mydomain.com document root to html\testsubdomain directory.

www.*.mydomain.com document root to  html\subdomain directory
                           (* any subdomain other than test)

I tried to edit vhost file but could not find vhost file in apache server. Generally where and how to achieve this?

Do I need to use Route53 for this?

Pradeep Charan
  • 653
  • 2
  • 7
  • 28

2 Answers2

2

"Create Record Set" form

To create sub domains you need to add entry in configuration file for each sub domain being created. You can either create new config files for each subdomain or keep adding in httpd.conf. I added in httpd.conf. the code should look like this.

<VirtualHost *:80>
ServerName sub1.domain.tld
DocumentRoot "var/www/html/sub1"
</VirtualHost>

<VirtualHost *:80>
ServerName sub2.domain.tld
DocumentRoot "var/www/html/sub2"
</VirtualHost>

This adds 2 sub domains sub1 and sub2. After this you need to create an A record in route 53 pointing to the IP of EC2 instance.

  • In the Name field, you can place * so that this A record would be valid for al the sub domains that will be created.
  • If you want the subdomain have be SSL Certified and have requested a Wildcard Certificate from ACM and attached to the EC2 instance through Eastic Load Balancer then choose "Yes" for Alias else choose "No"
  • Value has to be IP Address of your EC2 instance if no Alias chosen and if Alias is chosen you can provide the ELB here in this field.

Hope this helps...

crusy
  • 1,424
  • 2
  • 25
  • 54
Supriya
  • 31
  • 3
0

DNS simply maps a domain name like www.mydomain.com or test.mydomain.com to an IP address. You will use Route 53 to set up this initial mapping.

However, your webserver needs to be configured to respond to each host. This is done using virtual hosts in apache. (Similar configuration are available for other web servers.

datasage
  • 19,153
  • 2
  • 48
  • 54