Originally posted by Paco Loco:
<STRONG>On the PC I could use Microsoft Personal Web Server and set up a virtual directory for each site so it could be viewed successfully with internet explorer. I cannot do this with either Apple's Web Sharing feature or the Mac version of Personal Web Server.
There must be a solution out there - please help!</STRONG>
Hi Loco!
A virtual host setup for OSX's built-in Apache server is almost indispensable when you do local development.
That way you can "host" an infinite number of test sites and the host configuration can be setup individually for each of them. This is how you do it (for two test sites: foo_1.test and foo_2.test):
In "Netinfo manager" choose "Machines" and select "Localhost". In Edit menu choose "Duplicate" and rename the duplicate "foo_1.test". Repeat for foo_2.test.
This is similar to adding hosts in \drivers\etc\host in a Windows environment.
All you have to do now is to edit /etc/httpd/httpd.conf. Just do this (it's all at the bottom of the file):
NameVirtualHost 127.0.0.1
(note, if you have changed your documentroot put that here too):
<VirtualHost 127.0.0.1>
DocumentRoot /Library/WebServer/Documents
ServerName localhost
</VirtualHost>
And add the two testsites:
<VirtualHost 127.0.0.1>
ServerAdmin your_email_address
DocumentRoot /Users/your_username/Sites/foo_1
ServerName foo_1.test
ErrorLog "/private/var/log/httpd/foo_1.site-error_log"
CustomLog "/private/var/log/httpd/foo_1.site-access_log" common
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerAdmin your_email_address
DocumentRoot /Users/your_username/Sites/foo_2
ServerName foo_2.test
ErrorLog "/private/var/log/httpd/foo_2.site-error_log"
CustomLog "/private/var/log/httpd/foo_2.site-access_log" common
</VirtualHost>
Restart Apache and that should be it !! Now you have two sites to be stored in the folders foo_1 and foo_2 under /Sites, with individual error logging. Local addresses:
http://foo_1 and
http://foo_2.
Further server configuration can be setup individually under each virtualhost directive.
Hope this was legible!!