Previously wrote an article WAMP configuration Virtual host directory, details see WAMP Configuration Virtual Host directory, but recently do not know what the reason, the local environment using this way can not access to the corresponding directory, the case of baffled, a way to change.
Refer to the steps in the previous article.
Turn on the httpd.conf virtual host configuration
Include conf/extra/httpd-vhosts.conf
Configuring the Httpd-vhosts.conf File
Delete the original content, add the local root directory
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "C:/wamp/www" ServerName 127.0.0.1 ServerAlias www.dummy-host2.localhost ErrorLog "logs/dummy-host2.localhost-error.log" CustomLog "logs/dummy-host2.localhost-access.log" combined</VirtualHost>
This enables 127.0.0.1 to access the WWW root directory
Next we configure 127.0.0.2 so that it can access the phpMyAdmin
Continue adding configuration
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "C:\wamp\apps\phpmyadmin4.1.14" ServerName 127.0.0.2 ServerAlias www.dummy-host2.localhost ErrorLog "logs/dummy-host2.localhost-error.log" CustomLog "logs/dummy-host2.localhost-access.log" combined</VirtualHost>
Finally configure 127.0.0.3 to allow access to our own project root directory
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "C:/wamp/www/ihanzi" ServerName 127.0.0.3 ServerAlias www.dummy-host2.localhost ErrorLog "logs/dummy-host2.localhost-error.log" CustomLog "logs/dummy-host2.localhost-access.log" combined</VirtualHost>
So why do you configure this?
Many PHP developers use Xampp,wamp and other software to develop locally.
With a new project, create a new directory under the site root directory, such as test
Then the browser accesses through http://localhost/test/
Seemingly convenient, it is not, after the project transplant to the Internet, there will be many problems on the path, beginners should avoid this. So just follow the method in this article to write the project locally.
Wamp Configuring the Virtual Host directory (ii)