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

Can you please explain to me how I would do this, starting with the installation of Apache?

Are there multiple ways to do this? I would like the domain (eg http://intranet) available when you connect to the network, without editing the hosts file on every computer. Is that possible?

I would also like to create subdomains for my local URLs (eg http://site.intranet); can you tell me how to do this in Apache, and how to configure it?

Would I have to rename my computer to intranet, or is there another way to map the domain without editing each computer's configuration or workgroup (possibly through my router's settings)?

I would be very grateful if you could help me understand my options better, and tell me how to set up the server; thank you!

share|improve this question
1  
Really don't do this. "Custom" TLDs break enough RFCs that you should just buy the domain name that you want to use internally and use it. A few bucks a year isn't an overwhelming price. –  MDMarra Feb 16 '12 at 20:48
1  
@MDMarra I have several domain names, but I want to do this as a hobby project, really. –  ajmint Feb 16 '12 at 20:56
1  
I mostly agree with @MDMarra so consider buying the example.com domain and serving a separate corp.example.com domain from DNS servers reachable only from "internal" addresses. –  Luis Bruno Feb 17 '12 at 17:37
1  
@LuisBruno I could do that, but, as I said, I am mostly doing this as a hobby project. –  ajmint Feb 19 '12 at 15:24
    
Sorry, didn't mean to preach to the choir. It's just too easy to go with the default example.local domain that I just wanted to get that out in the clear. –  Luis Bruno Feb 19 '12 at 19:59

3 Answers 3

up vote 2 down vote accepted

It all hinges on DNS. You have to make sure that the DNS name intranet gets resolved to an IP address. I know how to do this only one way: installing my own DHCP and DNS service for the infrastructure. Bonjour-style should work as well, but I have no experience doing it that way.

The operating systems I know of support DNS suffixes, like .local or example.corp. You'll control the DHCP server on your network, correct? Lets assume it will give out addresses like 192.168.13.128, with a 255.255.255.0 network mask and most importantly, it will give out the address of a DNS server that knows how to answer authoritatively over the example.corp zone and it will say to the DHCP clients that their DNS domain is example.corp. Most operating systems will then try to access http://intranet.example.corp if you type http://intranet.

This is how the short-names will work. Onwards to name-based virtual-hosting, like @Iain said. Let's assume your Apache's configuration says:

Listen *:80
NameVirtualHost *:80

I'll assume the Apache server has the 192.168.13.1/24 IP address. I'd put an A record like s01.srv.example.corp. pointing at 192.168.13.1 and a CNAME like intranet.example.corp. pointing at s01.srv.example.corp. and if you need sub-sites I'd put in site.intranet.example.corp. as well, pointing at the full s01.srv DNS name.

Back to the Apache configuration: you'll need to add virtual-hosts like these:

# this matches the NameVirtualHost directive and
# loosely matches the Listen directive; it could also be:
# NameVirtualHost 192.168.13.1:80 and you'd change this below as well
<VirtualHost *:80>
    # notice you'll need both of these;
    # they must match what's in the browser Location bar
    ServerName intranet.example.corp
    ServerAlias intranet

    # sorry for the Unix-style paths, I avoid Windows a bit
    DocumentRoot /var/www/intranet.example.corp
</VirtualHost>

I don't mind expanding on this, if you need help. Please feel free to ask!

share|improve this answer

The technology you are after is name-based virtual hosting. You would typically configure your DNS server with an A or CNAME record that for each domain/subdomain that you want to serve that points to the address of your apache server.

You then use name-based virtual hosting to configure a vhost for each domain/subdomain.

share|improve this answer
    
Would I need to set up the DNS on my router? How would I do that? –  ajmint Feb 16 '12 at 20:18

Take a look at http://www.opennicproject.org they specialize in custom TLDs. They have a lot of information about setting them up and all their domains are free to use. My favorite is .geek lol then .pirate :P

You could also apply for a TLD now if you're a millionaire. Since I'm not it's open nic for me.

share|improve this answer
1  
OpenNIC, like it's predecessor AlterNIC Breaks The Internet. As a site for professionals recommendations for things that Break The Internet are not really appropriate here. –  voretaq7 Nov 11 '12 at 2:29

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.