Home >Backend Development >PHP Tutorial >localhost cannot be used after win10 apache configures virtual host
This article mainly introduces in detail the solution to the problem that localhost cannot be used after win10 apache configures a virtual host. It has certain reference value. Interested friends can refer to it. I hope it can help everyone.
win10 system configuration virtual host
1. Use Notepad or Sublime Text to open httpd.conf
ctrl + f Search httpd- vhosts.conf
Remove the # in
#Include conf/extra/httpd-vhosts.conf
and save
2. Open extra/httpd-vhosts.conf
Add the following content:
<VirtualHost *:80> ServerAdmin webmaster@youremail.com DocumentRoot "E:/your_web_root" ServerName your.web.com ErrorLog "logs/your_web_error.log" CustomLog "logs/your_web_access.log" common </VirtualHost>
3. For local testing , you also need to configure a domain name resolution entry in the hosts file, find the hosts file in the C:/windows/system32/drivers/etc/ directory
4. Complete the above steps After that, just restart Apahce
Here comes the key point
At this time, the domain name of the virtual hostwww.web.comcan be accessed normally, but localhost cannot be accessed. The error is reported as follows:
Solution:
There is a line of code in the httpd.conf file It needs to be commented out
ServerName localhost:80
Just comment out the line of code ServerName
Maybe the value localhost:80 is not in your httpd.conf file. It may be ServerName a.com:80; is the same, just comment it out and use it.
Afterwards, whether the virtual host is turned on or off, localhost can be accessed normally.
Related recommendations:
A case of php probe detecting virtual host configuration information
Detailed explanation of Linux virtual host related issues
About php Apache configuration virtual host
The above is the detailed content of localhost cannot be used after win10 apache configures virtual host. For more information, please follow other related articles on the PHP Chinese website!