Apache does not have access to localhost after configuration of the virtual host

Source: Internet
Author: User

Today want to try Php7, but found that PHP7 only support Apache2.4 version, and my Computer Apache is 2.2 version, in order to want to taste, you have to download the new Apache2.4

PHP7 and apache2.4 after the installation integration, localhost can be accessed normally, no problem.

Then I configured a few virtual host, this time, the virtual host can be normal access, but localhost will not be able to access.

In fact, I have experienced this problem before, for example, I used the php5.4 with Apache2.2, can be virtual host and localhost can be accessed;

But I did not remember how to solve the problem, and today again toss a long time, and finally found that, in fact, is to comment out a line of code things.

First, the process of configuring a virtual host:

1. Open the httpd.conf file and open the httpd-vhosts.conf

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

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

<virtualhost *:80>    "D:/amp/www/wechat"    ServerName www. WeChat.  COM</VirtualHost>

3. Open the Hosts file and add the domain name

127.0.0.1        www.wechat.com

4. Restart Apache, the domain name of the virtual host www.wechat.com can be accessed normally,

But my localhost will not be able to access it. The error is as follows:

Resolution process:

My idea is to add a virtual host called localhost.

1. Open the httpd-vhosts.conf file and configure a virtual host named localhost:

<virtualhost *:80>    ServerName localhost    "d:/amp/www" </VirtualHost>

2. Open the Hosts file and add the domain name

Note: This step, do or do not, have no effect, pro-test pass.

# 127.0.0.1        localhost

3. Restart Apache, the expected results did not appear, hey, are tired to death, or can not access localhost, although other virtual domain names can be accessed normally,

But I just want to have my cake and eat it, keep looking.

Problem solving:

In the end I compare my original configuration code, found that in the httpd.conf file there is a line of code that needs to be commented out

# ServerName localhost:80

This is the line of code, put me Out of trouble, ServerName this line of code to comment out on it.

Perhaps your httpd.conf file is not localhost:80 this value, may be ServerName a.com:80; All the same, directly comment out

LocalHost can be accessed normally, regardless of whether the virtual host is turned on or off.

Summary: Today recorded here, I made two mistakes, to ensure that no longer committed,

Then encounter problems, do not panic, patient search, always solve.

Apache does not have access to localhost after configuration of the virtual host

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.