标签:
我用的是xmapp lite2016的集成包,配置虚拟目录教程如下:
找到httpd-vhosts.conf这个文件,这个文件一般是在xampp\apache\conf\extra这个路径下面,找不到可以搜索下。
你会看到类似的界面:
#
# Use name-based virtual hosting.
#
##NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block.
#
#<VirtualHost *:80>
# ServerAdmin qingwangseo@qq.com
# DocumentRoot "/xampp/htdocs/"
# ServerName localhost
# ServerAlias localhost 127.0.0.1
# ErrorLog "logs/localhost-error.log"
# CustomLog "logs/localhost-access.log" common
#</VirtualHost>
直接取消虚拟机配置部分的注释,得到
<VirtualHost *:80> ServerAdmin qingwangseo@qq.com DocumentRoot "/xampp/htdocs/baidu" 备注:这里的根目录是你的目标文件夹 ServerName www.baidu.com ServerAlias www.baidu.com ErrorLog "logs/localhost-error.log" CustomLog "logs/localhost-access.log" common</VirtualHost>
把上面的百度域名换成你网站域名就可以,DocumentRoot "/xampp/htdocs/baidu"这个目录换成你的文件路径,我这里是www.baidu.com域名对应对应baidu文件夹。
以此类推,我们可以继续添加虚拟目录:
<VirtualHost *:80>
ServerAdmin qingwangseo@qq.com
DocumentRoot "/xampp/htdocs/tp5"
ServerName www.tp5.com
ServerAlias www.tp5.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin qingwangseo@qq.com
DocumentRoot "/xampp/htdocs/jianqingwang"
ServerName www.qingwang.com
ErrorLog "logs/www.qingwang.com-error.log"
CustomLog "logs/www.qingwang.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin qingwangseo@qq.com
DocumentRoot "/xampp/htdocs/bootstrap"
ServerName www.bootstrap.top
ErrorLog "logs/www.bootstrap.cn-error.log"
CustomLog "logs/www.bootstrap.cn-access.log" common
</VirtualHost>
好了,每个虚拟目录对应一个网站,你一台服务器就实现给N个网站服务的功能呢!
那么问题来了,如果一个网站有多个域名怎么办?这里有个ServerAlias参数就是为了配置多域名而生的,配置多域名方式如下:
<VirtualHost *:80>
ServerAdmin qingwangseo@qq.com
DocumentRoot "/xampp/htdocs/tp5"
ServerName www.tp5.com
ServerAlias www.tp5.com www.tp6.com www.tp7.com www.tp8.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
上面红色部分就是配置多域名,好了,教程就到这里,有错误的请大家指点。
PHP学习笔记:APACHE配置虚拟目录、一个站点使用多域名配置方式
标签:
原文地址:http://www.cnblogs.com/jianqingwang/p/5897566.html