Home  >  Article  >  Operation and Maintenance  >  What should I do if the apache virtual domain name configuration is invalid?

What should I do if the apache virtual domain name configuration is invalid?

王林
王林forward
2020-12-18 10:27:324854browse

What should I do if the apache virtual domain name configuration is invalid?

Background of the article:

Apache was reinstalled on the computer, but after configuring the virtual domain name, it has been unable to be accessed. Localhost always displays the it works status, and any configuration is entered. The domain name shows it works status, but the file directory can be seen through 127.0.0.1.

(Learning video sharing: Programming video)

Analysis:

The problem is in the httpd_conf file, just comment out ServerName localhost:80 That is Can.

Solution:

Start by configuring the virtual host:

Start with the host file in the system disk:

Add a domain name first : 127.0.0.1 www.m.com Open the httpd.conf file, open httpd-vhosts.conf:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Then open the httpd-vhosts.conf file, and configure a virtual host:

<VirtualHost *:80>
    DocumentRoot "D:/wamp/apache/htdocs"
    ServerName www.m.com
</VirtualHost>

Restart Apache. At this time, the domain name www.m.com of the virtual host cannot be accessed, and it still works;

Solution:

I configured several other virtual domain names first, but they are also inaccessible. The formulated file code;

Accessing through localhost is also because it works;

Finally, I found that I only need to comment out the following:

#ServerName localhost:80

in the httpd-vhosts.conf file , just restart apache!

Related recommendations: apache tutorial

The above is the detailed content of What should I do if the apache virtual domain name configuration is invalid?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete