Home > Article > Backend Development > PHP tips to solve the problem that localhost cannot be used after win10 apache configures a virtual host
This article mainly introduces in detail the solution to the problem that localhost cannot be used after win10 apache configures the virtual host. It has certain reference value. Interested friends can refer to
win10 system configuration virtual Host
1. Use Notepad or Sublime Text to open httpd.conf
ctrl f Search httpd-vhosts.conf
Remove the # from
#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 in the hosts file entry, find the hosts file in the C:/windows/system32/drivers/etc/ directory
4. After completing the above steps, just restart Apahce
Here comes the key point
At this time, the domain name of the virtual host 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 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.
The above is the entire content of this article. I hope it will be helpful to everyone's study. I also hope that everyone will support the php Chinese website.
Optimization of unique and exists validation rules in Laravel Detailed PHP example
php Method to determine if IP is a valid IP address php example
AES encryption class definition and usage example php skills implemented by php
The above is the detailed content of PHP tips to solve the problem that localhost cannot be used after win10 apache configures a virtual host. For more information, please follow other related articles on the PHP Chinese website!