title: How to host multiple domains and subdomains on single AWS EC2 instance
body: <p>I am trying to set up 2 domains (domain1.com and domain2.com) with a few subdomains (app.domain1.com) in AWS and run them on single instance (Amazon Linux, PHP, MySQL).</p>
  <p>I have set up 3 hosted zones in AWS Route53 with following configurations.</p>
  <blockquote>
  <p><strong>Hosted zone 1:</strong><br />
  domain1.com<br />
  Type A<br />
  52.108.XX.YY</p>
  <p><strong>Hosted Zone 2</strong><br />
  domain2.com<br />
  Type A<br />
  52.108.XX.YY</p>
  <p><strong>Hosted Zone 3</strong><br />
  app.domain1.com<br />
  Type A<br />
  52.108.XX.YY</p>
  </blockquote>
  <p>Additionally, I have added following code to the http.conf file in VirtualHost tag.</p>
  <pre><code>&lt;VirtualHost *:80&gt;   
       ServerName domain1.com   
       DocumentRoot &quot;/var/www/html/domain1&quot;   
       ErrorLog &quot;logs/domain1-error_log&quot;  
       CustomLog &quot;logs/domain1-access_log&quot; common  
       &lt;/VirtualHost&gt;
       
       &lt;VirtualHost *:80&gt;   
       ServerName domain2.com   
       DocumentRoot &quot;/var/www/html/domain2&quot;  
       ErrorLog &quot;logs/domain2-error_log&quot;  
       CustomLog &quot;logs/domain2-access_log&quot; common  
       &lt;/VirtualHost&gt;
       
       &lt;VirtualHost *:80&gt;  
       ServerName app.domain1.com   
       DocumentRoot &quot;/var/www/html/app&quot;  
       ErrorLog &quot;logs/app.domain1-error_log&quot;  
       CustomLog &quot;logs/app.domain1-access_log&quot; common  
       &lt;/VirtualHost&gt;
  </code></pre>
  <p>However, only domain1.com and domain2.com are getting resolved. When I visit app.domain1.com, it gives me a &quot;can't find server&quot; error. Please help how to setup the subdomain - is there problem in Hosted Zone setup or httpd.conf?</p>