Forum Moderators: phranque

Message Too Old, No Replies

Local Apache Vhosting

With subdomains?

         

ahmedtheking

10:28 am on Nov 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm running OS X and have configured Apache to work with PHP and so on. Can anyone suggest how I can go about configuring Apache to handle subdomains, ie testsite.localhost? This is that that I don't have to test in a relative state: localhost/testsite/

BjarneDM

9:39 am on Nov 27, 2006 (gmt 0)

10+ Year Member



1) you can't make subdomains to localhost as far as I know.
It's hardcoded in /etc/hosts. Entries in /etc/hosts are explicitly specified and can't be futher sub-divided. For that you'll need an actual DNS server.

2) the way I use is this:
2a) set up your virtual domains like you usually do
2b) edit /etc/host and point all of the test-domains to 127.0.0.1

eg. this is how my /etc/hosts looks:


[17:21:43@]$ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost

127.0.0.1 test.webadmin.info
127.0.0.1 test.mozilla.info
127.0.0.1 test.dtu.info

broniusm

9:54 pm on Nov 27, 2006 (gmt 0)

10+ Year Member



This also works whether or not the domain is registered (or while you're waiting for the registration propagate).

To do the same with a remote box, you'll want to dummy your local hosts file. In windows, the text file is something like:
c:\windows\system32\drivers\etc\hosts