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