Home > Article > Backend Development > How to deal with localhost being unavailable after win10 apache configures virtual host
This time I will bring you win10 apacheConfiguring the virtual hostHow to deal with the localhost being unusable after win10 apache is configured with the virtual hostWhat are the precautionsWhat are the following? This is a practical case, let’s take a look at it.
1. Open httpd.conf with Notepad or Sublime Text
ctrl f Search httpd-vhosts.conf
replace
#Include Remove the # from 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, and find the hosts file in the C:/windows/system32/drivers/etc/ directory
4. After completing the above steps, just restart Apahce.
The key point is here.
The domain name of the virtual host is www. web.com can 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 that needs to be commented
ServerName localhost:80
Just comment out the ServerName line of code
Maybe the value of localhost:80 is not in your httpd.conf file, it may beServerName a.com:80 ; are the same, just comment them out and use them.
Afterwards, whether the virtual host is turned on or off, localhost can be accessed normally.
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
How to operate PHP to record visitor browsing information
How to report an error when accessing array elements in double quotes in php deal with
The above is the detailed content of How to deal with localhost being unavailable after win10 apache configures virtual host. For more information, please follow other related articles on the PHP Chinese website!