multiple domain names on one os x machine?


John Galt Member
i checked other posts on, but they weren\\\'t really concise or substantive from a help standpoint. does anyone know how (if it <b>is</b> possible) to setup my os x machine to serve different local directories to different domain names? i don\\\'t believe i can just point 2 domains @ my ip address, for i believe those individual domains wouldn\\\'t know which directory to go to... any help or any info on how to be able to serve to multiple domains???

any help would be great,
I think you would need two NICs with two separate internet connections, and different IP addresses. If you have something like a cable modem, you can often get an extra IP address for a fairly low cost. Usually people use two different computers for the two IPs, but there\'s nothing stopping you from using just one computer

Once you have requests coming in on different NICs, you can set up your firewall to discriminate between them. So, if a TCP connection comes in on port 80, on en0, let it through to port 80. If it comes in on port 80 on en1, forward it to port 8080 (or whatever). (I assume it\'s wev serving you want to do)

Then you could have two instances of apache running, one listening on port 80, with one root directory, and one listening on port 8080, with another root directory.

For the firewall stuff, check out this article for the basics in human english, and the man page for ipfw for the details in computerese.

For the apache stuff, you\'re on your own, I just know that it can be done, not how.
OS X is completely capable of hosting multiple domains with ONE IP address and ONE network interface. This scenario isn't configureable via the GUI. It requires manual configuration of named and httpd. (if you are lost at this point I suggest trying Tenon's iTools... or learnimg more about DNS and Apache's virtual host feature).

Actually, it requires no configuration of named (unless of course you are hosting your own DNS, and if you are, you probably already know how to do this).

Simply have the domains point towards the same IP. This is perfectly legal. Its the reverse lookups that will confuse people, but of course, if you control your own .rev file, chances are you already stopped reading this.

The actual configuration of Apache is quite trivial. In the httpd configuration (uh, I think its /private/etc/httpd/httpd.conf though I'm not on my OSX machine right now so I can't verify this).

You'll use the BindAddress command to bind to a specific domain (ie: "BindAddress").

Then you'll setup your IP as a name-based virtual host by using the NameVirtualHost command (ie: "NameVirtualHost")

Then just setup the actualy virtualhost with the VirtualHost structure.

< VirtualHost >
DocumentRoot /www/docs/
# Other directives you might need to setup...
< /VirtualHost >

Send a hangup to your httpd daemon and you should be in business.

Edit: Argh, vBulletin clobbered the directives. Had to add spaces around them for it to work....

[Edited by Cadre on 01-11-2001 at 03:33 PM]
i can't edit my httpd.conf file because i don't have one!
i have the following <b>3 (three)</b> files:

which one should i edit to assign multiple anmes with the <VirtualHost> tag?

also, where (about) in the file is this stuff located?

i found the file i need to edit (it's actually apache.conf)

but, where do i put the virtualhost info for multiple domains? i found the point at which it tells the computer the following:

is this where i put virtualhost stuff? also, they are separated by lines with # (comments i guess). i need some tutoring on this stuff. please don't yell at me, i'm new to this unix stuff. i'm trying to learn.

any help would be <b>greatly</b> appreciated,
I believe virtualhost host directives can go anywhere in apache's main configuration file (httpd.conf apache.conf, whatever it may be called). You usually see them at the end of the file... or in a seprate file to keep things neat (Inculde "file_name").

Here is an example....

DocumentRoot /export/home/casey/
I haven't got my OS X box in front of me, so I can't tell you where it is exactly, but there's pretty decent HTML documentation included with Apache--tells you where to put all of these things. You should be able to find it by poking around in the Apache folders (or try Sherlock).
The file you want to edit is, indeed, httpd.conf (it *may* be different in OS X before 10.1.3).

It should be located at /private/etc/httpd/httpd.conf (since it's in /private, Sherlock will not find it).

You'll want to put the <VirtualHost *> container at the end of the file, but before any Include statements.

The html documentation mentioned before can be found here:

Also, the httpd.conf file on all the OS X boxes I have access to (a couple different versions of X) all have extensive commenting, so you can just read through that for more detail.

One other note, if your server doesn't have it's own static, public IP address, you'll probably need to give it the NameVirtualHost command and then specify the private IP of that machine (i.e. You've got DSL with 1 static IP but you're sharing it with 3 computers using 10.x or 192.168.x addresses), otherwise Apache seems to get confused.