You could still use a hosts file, but you'll need to assign multiple addresses to your server's Ethernet interface. You can do this in /etc/network/interfaces as discussed here.
Suppose you assign 192.168.1.1 to eth0 and 192.168.1.2 to eth0:0, the first virtual adapter. In Apache you would include separate <VirtualHost> definitions, one for each IP/ServerName combination:
Code:
<VirtualHost 192.168.1.1:80>
ServerName www.domain1.com
DocumentRoot /path/to/some/location
[etc.]
</VirtualHost>
<VirtualHost 192.168.1.2:80>
ServerName www.domain2.com
[etc.]
</VirtualHost>
Just make sure your /etc/hosts files map www.domain1.com to 192.168.1.1 and www.domain2.com to 192.168.1.2.
Notice that these declarations use the full "IP:80" specification in the <VirtualHost> directive, not the "*:80" that is used for name-based virtual hosting.
Bookmarks