Open a virtual host in Apache

Source: Internet
Author: User

Recently in the self-study lamp, in Apache try to open the virtual host, encountered quite a lot of trouble, here also by the way summed up,
When opening a virtual host in Apache, there are several main steps:

1. Create a new folder as a virtual host to store site resources
For example, I created a new Htdocs_v folder in the Apache directory, and a new PHP file was created with the following content:

<? PHP   Echo ' This is the first virtual host ';? >


2. Open the virtual host in the configuration file:
Opens the apache/conf/httpd.conf file,
Modify the following code:



3. Configure the virtual host
Opens the apache/conf/httpd-vhosts.conf file,
Add the configuration information to the virtual host:

<*:80>    documentroot "E:/apache/htdocs_v"  ------------------ The location of the virtual host    ServerName www.sina.com            ------------------site-    bound domain name <"e:/ Apache/htdocs_v ">   -----------------Be sure to remember to add access     permissions to the folder allow from all </ Directory > </ VirtualHost >

4 . Modify the local DNS resolution database:
In the C:\Windows\System32\drivers\etc\hosts file, add the following code at the end

127.0.0.1 www.sina.com

Bind the domain name with the local IP, so that when entering the "Domain name \php file" in the address bar, the server enters this host, finds the location of the virtual host, runs it
The PHP file

5. Operation Result:

In the process, may be due to browser buffering problems, the results are always difficult to appear ~ ~, and remember to modify the Apache configuration file, remember to restart Apache.

Open a virtual host in Apache

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.