Ive configured Apache for Name-based Virtual Hosting but I can’t seem to get a local site to show in my browser. Is my httpd.conf misconfigured? Here’s the sanitized version:
#
# Use Name-based Virual Hosting.
#
NameVirtualHost *.:80
#
#Set up permissions for VirtualHosts in ~/Sites
#
<Directory "/Users/myusername/Sites">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# For http://localhost in the OSX default location
<VirtualHost _default_:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents
</VirtualHost>
<VirtualHost *:80>
ServerName thewebsite.local
CustomLog "/Users/myusername/Sites/logs/thewebsite.local-access_log" combined
ErrorLog "/Users/myusername/Sites/logs/thewebsite.local-error_log"
DocumentRoot "/Users/myusername/Sites/thewebsite.local"
</VirtualHost>
And my 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 thewebsite.local
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
Try changing the first line to be
NameVirtualHost *:80instead ofNameVirtualHost *.:80.Also, add your documentRoot for
_default_in quotesDocumentRoot "/Library/WebServer/Documents"(just to be consistent across the file.)Also try adding the Directory permissions inside the Virtual Host.
I have made the changes in the code below. Try them.