0

I have 3 subdomains websites. Those are subdomain1.mydomain.com, subdomain2.mydomain.com, subdomain3.mydomain.com. I have point these to the external IP address. bind is ok, dig is onerror, Apache2 reload ok

1.) If I set the following, I can only see the first one alphabetically.

NameVirtualHost *:80    
<VirtualHost *:80>    
   ServerName subdomain1.mydomain.com
...    
<VirtualHost *:80>    
   ServerName subdomain2.mydomain.com
...

2.) If I set the following, I get file not found. Apache2 reload ok.

NameVirtualHost mydomain.com:80    
<VirtualHost mydomain.com:80>    
   ServerName subdomain1.mydomain.com
...
<VirtualHost mydomain.com:80>    
   ServerName subdomain2.mydomain.com

Please Help! What else should I do.

5
  • What do you mean by "see" the website?
    – mdpc
    Oct 26, 2012 at 20:15
  • Please provide the output from apachectl -S Oct 26, 2012 at 20:15
  • I mean I browse it from outside the network with another IP address.
    – Victor
    Oct 26, 2012 at 20:20
  • apachectl -S apachectl: command not found
    – Victor
    Oct 26, 2012 at 20:22
  • apache2ctl -S IP:80 is a NameVirtualHost // I have NameVirtualHost mydomain.com here, why it become IP port 80 namevhost subdomains.mydomain.com(/etc/apache2/sites-enable/subdomain1.mydomain.com:56) // what is the last number stand for ??
    – Victor
    Oct 26, 2012 at 20:35

2 Answers 2

0

you should have following:

NameVirtualHost IP:80

<VirtualHost IP:80>
  ServerName subdomain1.mydomain.com
  ...
</VirtualHost>

<VirtualHost IP:80>
  ServerName subdomain2.mydomain.com
  ...
</VirtualHost>

* UPDATE *

Name-based Virtual Host Support - Apache HTTP Server

3
  • I want to use name base
    – Victor
    Oct 26, 2012 at 20:30
  • what I provided IS a name based virtualhost, look at URL to read more how to configure it properly
    – alexus
    Oct 26, 2012 at 20:40
  • after you configure it use httpd -S to see how apache sees your configiuration
    – alexus
    Oct 26, 2012 at 21:01
0

See http://wiki.apache.org/httpd/CommonMisconfigurations

Your first code sample is correct. You should use wildcards, e.g. NameVirtualHost *:80 and <VirtualHost *:80>, otherwise you can not reliably test it from the same machine.

From your comment:

I mean I browse it from outside the network with another IP address.

You must test it using the DNS name (or a hosts file entry, or defining the HOST header)

3
  • If you have registered a domain name: curl http://domainname/. If you haven't registered a domain name: `curl -H "Host: domainname" ipaddr" Oct 26, 2012 at 21:03
  • Hi, Fuzzyfelt. I have try curl subdomain1.mydomain.com which come up the home page with noframes in ubuntu. But for curl subdomain2.mydomain.com there no reaction. Why? and what does it means?
    – Victor
    Oct 27, 2012 at 17:49
  • @Victor Please update your question with details about how you've registered subdomain2.mydomain.com to your IP address, the result from dig subdomain2.mydomain.com, where you're testing from and the exact output from curl. Oct 27, 2012 at 19:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .