How do I host 2 different website names at the same IP address?

I'd like to host two websites with different domain names, on a single server, with a single IP address.

I have a fixed IP address with my service provider. It points to my router which port forwards everything on port 80 to a mac mini server on my local network.

How would I get that mac mini server to host two different websites on the same IP address?

Do I need to play around with the DNS on the Mac, or on the router (which is the entry point for the fixed IP address)? IE on the local network, does each domain name needs its own IP address so that these can be resolved by the single server? Little confused as to where to start. Thanks for help.


Solution 1:

Set up a virtual host. See the following docs

http://httpd.apache.org/docs/2.2/vhosts/

Once you've set this up you can test it locally by adding an entry to your hosts file.

See: http://support.apple.com/kb/TA27291

e.g.

host1   <your ip address>
host2   <your ip address>

then browse to http://host1 and http://host2

Solution 2:

Apache, and most other webservers, can use the one IP address to respond to different domain names requests. This generally works well, unless you need SSL. Apache is the webserver used by MacOS X Server.

Apache calls this functionality Name-Based Virtual Hosts.

You easily create new virtual hosts on MacOS X Server using the Server Admin program -> Web -> Sites.

Apple provides extensive documentation on MacOS X Server at http://www.apple.com/server/macosx/resources/documentation.html. See the section "Managing Multiple Sites on One Server" of the Web Technologies Administration PDF.

And you will need an external domain name pointing to the mac mini's external IP address for each web site/domain name.

Marcus