Apache Virtual Host

Source: Internet
Author: User

After the XAMPP is installed, open the browser, enter the URL "http://localhost" or "HTTP://127.0.0.1/", the browser appears on behalf of the successful installation.

The default local path of the Web page is "C:\xampp\htdocs", the original file in this directory can be deleted all, and then create a new file yourself ("index.html" or "index.htm" or "index.php" is the default page).

Apache is a server software that configures Apache virtual hosts to run multiple Web sites on a single server, each of which binds separate domain names and binds them to separate directories.

In the Windows environment.

The first step: Open the C:\Windows\System32\drivers\etc\host file, add "127.0.0.1 www.test.com" in the file, 127.0.0.1 means the IP address of the machine, "127.0.0.1" and " Www.test.com "There are several spaces between. "Www.testlz.com" is the virtual domain name set by the machine owner.

Such as:

You can also set up two virtual domain names

This way, entering http://www.test.com/and http://www.test.com/in the browser is the same as entering localhost. They point to the contents of the same directory.

Next, you can set each virtual domain name to point to a different, separate directory so that you can achieve the purpose of running multiple projects on the same server.

In Win7 environment, open C:\xampp\apache\conf\httpd.conf, find

This line, and remove the "#" in the red circle. This way, Apache will not load the conf/extra/httpd-vhosts.conf file until it is booted.

Then open the Httpd-vhosts.conf file and add the following, both Www.hello.com and www.test.com are the domain names when they are published externally.

and create the corresponding folder in the C:\xampp\htdocs directory, and put the HTML file in the folder. ,

This successfully configures two items when input http://www.test.com/is, pointing to the contents of the Test folder. Enter http://www.hello.com/to display the contents of the Hello folder

If you do not configure the httpd-vhosts.conf file, the input http://www.test.com and http://www.hello.com/will not enter the test and the Hello folder, both the path configuration is invalid, the browser is displayed

Apache 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.