Home >Backend Development >PHP Tutorial >Detailed explanation of local machine apache configuration of virtual host based on domain name_PHP tutorial

Detailed explanation of local machine apache configuration of virtual host based on domain name_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 14:58:44867browse

1. Open the httpd.conf file of apache and find
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
Include this section Remove the "#" in front of conf/extra/httpd-vhosts.conf.

2. Modify the hosts file located in the (win7)c:/windows/system32/drivers/etc/ directory
Add a paragraph: 127.0.0.1 x.acme.com (the domain name you use to access)

3. I use the wamp package, so go to c:/wamp/bin/apache/Apache2.2.11/conf Modify the file httpd-vhosts.conf in the /extra directory

The default NameVirtualHost is as follows:
NameVirtualHost *:80

Added:

ServerAdmin x@acme.com
DocumentRoot "/var/www/html"
ServerName x.acme.com
ErrorLog "logs/x.acme.com -error.log"
CustomLog "logs/x.acme.com-access.log" common


Change it and restart the server.
Enter http://x.acme.com in the browser to go to your directory.

Of course, if you want to add a virtual host to the existing web server, then the original localhost If the service is to be usable, you need to add something on top of the above:
Add: 127.0.0.1 localhost
to the hosts file and add:
ServerAdmin localhost@xxx.com
DocumentRoot "/var/www/"
ServerName localhost
ErrorLog "logs/ localhost-error.log"
CustomLog "logs/ localhost-access. log" common

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328189.htmlTechArticle1. Open apache’s httpd.conf file and find # Virtual hosts #Include conf/extra/httpd-vhosts. conf In this section, remove the "#" in front of Include conf/extra/httpd-vhosts.conf. 2. Modify the location (...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn