I'm trying to get the Apache server that comes with OS X to work for my local website. No matter what I change the file httpd-vhosts.conf
to, when I run httpd -S
in Terminal it says my virtual host syntax is OK. I typed in a bunch of random characters into the file, restarted Apache, and it still says my configuration is OK.
First I edited /private/etc/hosts
and added this line underneath 127.0.0.1 localhost
:
127.0.0.1 mysite
Then I edited /private/etc/apache2/httpd.conf
. I uncommented this line:
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
I also uncommented the PHP5 line to enable PHP.
Next I edited /private/etc/apache2/extra/httpd-vhosts.conf
and set up my virtual hosts. After restarting apache, my virtual hosts were not working and running httpd -S
said my virtual hosts syntax was OK. No erros in the Apache error log. This is what the httpd-vhosts.conf
file contained:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Users/Gavin/Web"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/Gavin/Web/mysite/public_html"
ServerName mysite
</VirtualHost>
No matter what I did, my virtual hosts would not work. So I tried changing httpd-vhosts.conf
to this:
NameVirtualHost *:80
<VirtualHost @*^#*&^#$>
(#*&#*$&@(*UOSKSFLKSFJLJF##*(&
</VirtualHost>
I restarted Apache using sudo apachectl restart
and then ran apachectl -S
and it says:
httpd: Could not reliably determine the server's fully qualified domain name, using Gavins-MacBook-Pro.local for ServerName
VirtualHost configuration:
Syntax OK
Obviously my httpd-vhosts.conf file is not OK, so which file is it loading? In Terminal I ran httpd -V|grep SERVER_CONFIG_FILE
and it returned:
-D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"
That's obviously the correct httpd.conf
file, so what's going on here? Any ideas?