Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Rower_CPU

Moderator emeritus
Original poster
Oct 5, 2001
11,219
3
San Diego, CA
OK, hopefully someone here has some experience with this and can let me know what's going wrong with my setup.

I'm trying to set up a couple of virtual hosts with Apache on my PowerBook for work. I've found how-to's at a couple of places, but nothing has worked so far.

- SitePoint - Configuring OS X for Web Development
- evolt - Enabling Virtual Hosts on MacOS X

I'm pretty sure my httpd.conf is fine, but damned if I can get /etc/hosts of NetInfo to allow me to type http://mysitename and get to my local sites.

I'll post config file contents in a minute...
 
He's pointing to the same evolt article I linked above at the end of that post...still no go.

Here's my httpd.conf section on virtual hosts:
Code:
NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
    DocumentRoot /Library/WebServer/Documents
    ServerName localhost
</VirtualHost>

<VirtualHost 127.0.0.1>
    DocumentRoot /Volumes/myservername
    ServerName myservername
</VirtualHost>
 
DNS shouldn't factor into this since it's using the local hosts info. Take a look at the Apache config info - I'm trying to reach a local volume.
 
I guess I should look a little deeper <grin>

Ok, so we know that you have a localhost of the standard 127.0.0.1, and that you have told apache to use virtual names when the browser looks up a name.

Now, when the browser tries to resolve http://mysitename to an IP, does the entry exist /etc/host that redirects the name to localhost? can you ping mysitename?

Would it be possible to post your /etc/host.

BTW: just for clarification, I would like to diagram what I know of this process. I do not mean to insult anyone's knowledge, but I would like to make sure we are on the same page :

Browser -> call site by name - > resolve site name to IP -> contact apache by IP -> Apache looks up name calling it -> depending on name, redirects files from specified site.

I am pretty certain this is the way things work here. Please correct me if I am wrong, as it have been a couple of years since I did this type of work on Apache.

Max.
 
Try this

Your apache conf
PHP:
NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot /Library/WebServer/Documents
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /Volumes/myservername
    ServerName myservername
</VirtualHost>

and your host file

PHP:
127.0.0.1 localhost myservername

Im curious what IP your apache is listening on, won't matter if you use a wildcard in your apache conf file.

Good Luck!
 
max-
I can ping the sitename ("LARC" in this instance). Here's my hosts file, using kingjr's format:
Code:
127.0.0.1   localhost
255.255.255.255   broadcast
::1   localhost
127.0.0.1   localhost   LARC

kingjr-
It's listening on 127.0.0.1 - just the loopback address. I'm going to be traveling so there's no point in setting a particular IP.

Trying with your "*:80" format it's still not working. Based on me being able to ping the virtual name, I think we're narrowing it down to Apache not handling it correctly...hmmm.

I've been restarting Apache after any change to the config file, but none of the tutorials say anything about resetting anything for the host file changes to take place. Is it not necessary? I've rebooted a couple time to see if it did anything, but no dice.

Thanks for the help thus far, folks - it's rare for me to get hung up on something, especially when the tutorials make it seem so straightforward.
 
Yeah, I came across that one, too but all the other tutorials seemed more straightforward.

Guess I'll give it a shot...though I'm not convinced my hosts settings are wrong, since I can ping "LARC" and it resolves to 127.0.0.1.
 
I'm no Unix buff so I use this script to set up my local sites so that they can be accessed by http://clientname. It works great and makes life simple :D.

I still have some issues viewing dynamic sites across a network (I think it's something to do with include paths in PHP, dots and slashes :eek:).
 
That script seems to work great - but I'm still stuck with non-functioning virtual hosts on both machines I've tried.

I've tried different virtualhost names and paths on a PowerBook and a PowerMac (both running 10.3.6) and neither one works. The only thing I can think of now is that the PHP/MySQL install I've done on these machines is interfering somehow...
 
OK, I've gotten one to work with a folder in my ~/Sites directory using the script from Patrick's site...but anything in /Library/WebServer/Documents/ or /Volumes seems not to work. I know I'm modifying the file that results from that script correctly to repoint to the directories I want - still not sure why it's not working. :confused:

update - Finally! It's working great now.

Thanks again for all the help everyone. Not sure why I had such trouble, but I'm glad it's working now. :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.