First you need to remove the dummy definition examples from your vhost-httpd.conf file. They are provided as examples only to get started with the syntax and should not remain in the active conf/extra/httpd-vhosts.conf , since they point to non-existent folders.
Therefore, remove these 2 definitions from the file:
<VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "g:/Apache24/docs/dummy-host.example.com" ServerName dummy-host.example.com ServerAlias www.dummy-host.example.com ErrorLog "logs/dummy-host.example.com-error.log" CustomLog "logs/dummy-host.example.com-access.log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "g:/Apache24/docs/dummy-host2.example.com" ServerName dummy-host2.example.com ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common </VirtualHost>
The second Apache 2.4.x supports IPV4 (127.0.0.1) and IPV6 (:: 1), so your hosts should look like this with the IPV4 and IPV6 version definitions for each site. The browser can use either of them arbitrarily, so you will need both options, but it will probably use the IPV6 network instead of IPV4 if both are actually active on your computer.
127.0.0.1 localhost ::1 localhost 127.0.0.1 mysite.dev ::1 mysite.dev
Now on the 2 virtual hosts that really exist on your system, try this as defining a virtual host:
<VirtualHost *:80> DocumentRoot "g:/wamp/www" ServerName localhost ServerAlias localhost ErrorLog "logs/localhost-error.log" CustomLog "logs/localhost-access.log" common <Directory "G:/wamp/www"> AllowOverride All Options Indexes FollowSymLinks Require local </Directory> </VirtualHost> <VirtualHost *:80> DocumentRoot "g:\wamp\www\mysite\public" ServerName mysite.dev ServerAlias www.mysite.dev ErrorLog "logs/mysite-error.log" CustomLog "logs/mysite-access.log" common <Directory "G:/wamp/www/mysite/public"> AllowOverride All Options Indexes FollowSymLinks Require local </Directory> </VirtualHost>
The <Directory>....</Directory> section of the <VirtualHost>....</VirtualHost> section tells Apache which IP addresses it is allowed to accept connections from, so using the Apache 2.4 Require local syntax restricts access, so only the PC running WAMPServer, that is, Apache, can connect to any of these sites.
Try not to mix Apache 2.2 syntax and Apache 2.4 syntax together in one definition. So do not use
Order Allow,Deny Allow from all
and
Require all granted
in the same definition. You are using Apache 2.4, so use the Apache 2.4 syntax.
If you find that you want other PCs on your local network to see your site, for example, a partner or children, etc., you can add this syntax to one or more definitions of your virtual host.
Allow only one other computer to your site
Require local Require ip 192.168.1.100
or 2 other computers
Require local Require ip 192.168.1.100, 192.168.1.101
Or someone on your LAN just use the first 3 of 4 quartiles of the IP address.
Require ip 192.168.1
Also avoid using syntax that allows access from anywhere, i.e.
Require all granted <--Apache 2.4 syntax or Order Allow,Deny <-- Apache 2.2 syntax Allow from all
This may solve your problems in the short term, but just waiting to catch you after a while, when you decide that you want to show your site to a friend / client / boss. If you reach the “Port Forwarding” stage of your router, so that the world will be included in your network, which will make ALL YOUR SITES available to the whole world.
It is better to change the definition of ONE virtual host for the ONE site that you want people to see for testing / boasting from Require local to Require all granted and allow access to this only site only from the Internet.
After making all these changes, be sure to restart Apache.
Also, if you modify the hosts file to activate chnages, you must either restart the computer or start them from the command line command line launched with the Runs as Administrator parameter.
net stop dnscache net start dnscache
If you are using Windows 10, the above dns commands no longer work, you should do this instead.
ipconfig /flushdns