Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a single physical server. I need to set it up so i can have 3 different domains on it. Each one of these domains needs to be able to support wildcard sub-domains. (.example.com,.example2.com,*.example3.com) I can purchase two more ips if this will make things easier.

The current setup is as follows

www.example.com => default vhost

devel.example.com => development server this is the only server that currently accepts *.example.com

staging.example.com => only works via staging.example.com

essentially i need all of these different to accept a wild card subdomain which i why i believe i need separate domain names for each.

What is the best way to get this all setup?

Thanks in advance.

share|improve this question

1 Answer 1

You can create the wildcard domain up via DNS. For each domain that will be different, however, you will need to create a subdomain for it via DNS. Setup the Apache configuration using the ServerAlias and ServerName for your main subdomain and ServerAlias for your subdomains:

<VirtualHost IP:80>
    ServerAdmin root@localhost
    ServerName www.example.com
    ServerAlias example.com
</VirtualHost>

<VirtualHost IP:80>
    ServerAdmin root@localhost
    ServerAlias devel.example.com
</VirtualHost>

<VirtualHost IP:80>
    ServerAdmin root@localhost
    ServerAlias staging.example.com
</VirtualHost>

You could use .htaccess to do the same thing I believe, but I like doing it this way better - personal preference.

share|improve this answer
    
in this configuration i would need a separate ip for each... correct? –  user52177 Aug 24 '10 at 17:19
    
Sorry for the delay! Nope, you can use NameVirtualHost IPADDRESS:80 above your VirtualHosts, and then use that IP address in your VirtualHost IPADDRESS:80 stanza. –  drewrockshard Aug 24 '10 at 18:27
    
So that it is easier to read, I created a private pastie for you - here's what part of it would look like: pastie.org/private/x5uxpvgfnfdrffypkrr71g –  drewrockshard Aug 24 '10 at 18:29
    
im going to test this out tomorrow i will be sure to post back with my results.. thanks again –  user52177 Aug 24 '10 at 20:06
    
No problem! Let us know if you run into any snags. –  drewrockshard Aug 24 '10 at 20:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.