I'm running Apache 2.4 on Yosemite

This is my /private/etc/apache2/httpd.conf

DocumentRoot "/Library/WebServer/Documents/home_www/"
<Directory "/Library/WebServer/Documents/home_www">   
    Options Multiviews FollowSymLinks
    MultiviewsMatch Any
    AllowOverride All
    Order allow,deny
    Allow from all

With this setting I can use and http://localhost in the web browser then it directs me to /Library/WebServer/Documents/home_www/index.html as usual

Then I added Include /private/etc/apache2/extra/httpd-vhosts.conf because I would like to use vhost on my machine

This is my /private/etc/apache2/extra/httpd-vhosts.conf

<VirtualHost *:80>
    ServerAdmin jeud@hotmail.com
    ServerName tutor4dev.local 
    DocumentRoot "/Library/WebServer/Documents/home_www/xxx"

I tried to use sudo apachectl -S to display vhost configuration, there are the result

VirtualHost configuration:
*:80                   xxx.local (/private/etc/apache2/extra/httpd-vhosts.conf:28)
ServerRoot: "/usr"
Main DocumentRoot: "/Library/WebServer/Documents/home_www/"
Main ErrorLog: "/private/var/log/apache2/error_log"
Mutex proxy: using_defaults
Mutex default: dir="/private/var/run/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/private/var/run/httpd.pid"
User: name="_www" id=70
Group: name="_www" id=70

I can use http://xxx.local to access /Library/WebServer/Documents/home_www/xxx/index.html (vhost), but after adding vhost, and http://localhost also direct me to /Library/WebServer/Documents/home_www/xxx/index.html instead of /Library/WebServer/Documents/home_www/index.html

Please guide how to fix it Thanks

1 Answer 1


You have only one VirtualHost, and with * in it (<VirtualHost *:80>). Your main server will never answer any request. All requests will be handeld by the first virtual host configured, which is the default server in case of name based virtual hosts. You should create a new virtual host that must appear before all others in your config file(s) like:

# Main server, catches all requests that do not correspond to a ServerName/Alias
<VirtualHost *:80>
    DocumentRoot "/Library/WebServer/Documents/home_www/"

More info in the apache doc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.