Step one: Open the C:/WINDOWS/system32/drivers/etc/hosts file with Notepad (win7 hosts file location: %systemroot%system32driversetc),
Under 127.0.0.1 localhost, I added a 127.0.0.1 localhost.tuolarapp.com, so that every time I enter localhost.tuolarapp.com in the browser, it will no longer resolve to the network DNS, but directly resolve to the local. So in fact you can’t access localhost.tuolarapp.com. Of course, you can also set it to sohu.com if you like.
Second step:
Because my xampp is installed on the D drive: Use Notepad to open the D:/xampp/apache/conf/httpd.conf file, and I found Include "conf/extra/httpd-vhosts. conf", make sure there is no #.
in front of it
Step 3: D:/xampp/apache/conf/extra/httpd-vhosts.conf, add the following code segment at the end:
Or the details are as follows:
<VirtualHost 127.0.0.1:80> DocumentRoot "D:/tuolarapp" ServerName "localhost.tuolarapp.com" </VirtualHost>
Then save and restart apache, so that when I enter localhost.tuolarapp.com in the browser, it will automatically resolve to the website in the directory D:/tuolarapp. In this way, input is much more convenient, and the key to self-feeling will be better.
<VirtualHost 127.0.0.1:80> DocumentRoot "D:/tuolarapp" ServerName "localhost.tuolarapp.com" <Directory "D:/tuolarapp"> Options Indexes FollowSymLinks ServerAlias 1.com *.2.com ErrorLog logs/www.eachbrand.com-error_log CustomLog logs/www.eachbrand.com-access_log common AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
Explain each of the above configuration elements as follows:
localhost is the website domain name. Port 80 does not need to be written. If it is changed to another port, it needs to be written. At the same time, httpd.conf must be modified. Listening port number: Listen 80
ServerName:
Website domain name, same as above, must be filled in;
DocumentRoot:
Home directory of website program, must be filled in;
Options Indexes FollowSymLinks:
Display the directory list. If you want to set a safe point, you can remove Indexes and not display the directory list. It is not necessary;
Alias:
can be accessed through multiple domain names;
ErrorLog:
Error log file storage location;
CustomLog:
Access log file storage location;
ResinConfigServer:
The Resin server listening port, my local one is: 127.0.0.1, if there are multiple machines as servers, just change it to the corresponding IP address;
The above completes the configuration of the virtual host. A website corresponds to a
What if you want to run the site under other ports?
It's very simple: in the "httpd.conf" main configuration file, set multiple ports, such as Listen 8081
How to use xampp to build a virtual host running php. I believe it will not be difficult for you if you encounter similar problems in the future. I hope you will like this article.