MacOS – Localhost to custom page

apachemacoswebserver

I am running macOS 10.12.5 and I am setting up a localhost and everything looks correct. I used brew to install Apache (httpd), MySQL, and PHP. I have changed the hosts file to point the localhost to the custom site and changed the vhost to:

<VirtualHost *:80>
  ServerAdmin webmaster@dummy-host.example.com
  DocumentRoot "/Users/me/site"
  <Directory /Users/me/site/>
    ServerName me.com
    ServerAlias www.me.com
    ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>`

I have updated httpd.conf to include the vhost file and the appropriate php modules needed.

When accessing 'localhost' by either 127.0.0.1 or the site name itself I receive the It Works! page instead of the files located in

DocumentRoot "/Users/me/site"
<Directory /Users/me/site/>

Best Answer

You actually have some errors in the config snippet you posted, try this:

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Users/me/site"
    ServerName me.com
    ServerAlias www.me.com
    ErrorLog /private/var/log/apache2/dummy-host.example.com-error_log
    CustomLog /private/var/log/apache2/dummy-host.example.com-access_log common
</VirtualHost>

You don't need to <Directory> section for these directives, and you were missing the closing </Directory>. This might have caused Apache to not load your config and serve the default virtualhost instead.