博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
wampserver环境下,apache本地下设置多个域名
阅读量:6986 次
发布时间:2019-06-27

本文共 4250 字,大约阅读时间需要 14 分钟。

Apache在安装之后默认只是指向一个站点,即127.0.0.1,如果要进行多站点的配置,需要更改一些配置。

步骤、方法:

1,)让Apache在启动时能加载虚拟主机模块。

打开Apache安装目录下conf/httpd.conf文件,找到下面两行文字,把最前面的 # 号去掉,然后保存。

#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule rewrite_module modules/mod_rewrite.so
#Include conf/extra/httpd-vhosts.conf

2,)接下来还是在httpd.conf中找到DocumentRoot 和 Directory节点,如果我们的站点设置在:

example001站点地址:"d:/wamp/www/example001"

example002站点地址:"d:/wamp/www/example002"

那么修改配置如下:

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
#AllowOverride None
# modify @2015-09-19
AllowOverride All
Order deny,allow
Deny from all
</Directory>

#

# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#

# This should be changed to whatever you set DocumentRoot to.
#
<Directory "d:/wamp/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all

#

# Controls who can get stuff from this server.
#

# onlineoffline tag - don't remove

Order Deny,Allow
Deny from all
#Allow from 127.0.0.1
# modify @2015-09-19
Allow from all
</Directory>

3,)完成以上配置保存后,找到路径conf/extra/httpd-vhosts.conf进行配置:

备注:

<VirtualHost *:8080>

#ServerAdmin是站点管理员邮箱

ServerAdmin webmaster@dummy-host.example.com    

#DocumentRoot 是站点根目录

DocumentRoot "c:/Apache2/docs/dummy-host.example.com"

#ServerName 是站点网址

ServerName dummy-host.example.com

#ServerName 是站点网址扩展

ServerAlias www.dummy-host.example.com

#ErrorLog 是站点错误日志存放路径

ErrorLog "logs/dummy-host.example.com-error.log"

#CustomLog 是站点客户端访问日志存放路径

CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

#

# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#

# Use name-based virtual hosting.
#
NameVirtualHost *:8080

#

# 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 *:8080>
# ServerAdmin webmaster@thinkphp_blog.com
# DocumentRoot "D:\wamp\www\thinkphp_blog"
# ServerName www.thinkphp_blog.com
# ServerAlias www.thinkphp_blog.com
# ErrorLog "logs/thinkphp_blog.com-error.log"
# CustomLog "logs/thinkphp_blog.com-access.log" common
#</VirtualHost>
<VirtualHost *:8080>
#管理员邮箱
ServerAdmin admin@cnmiss.cn
#根目录
DocumentRoot "d:/wamp/www/blog"
#默认域名
ServerName tblog001.com
#用*表示泛域名,如果要接收三级泛域名解析,可以写成这样:*.my.cnmiss.cn
ServerAlias *.tblog001.com
#错误日志
ErrorLog logs/tblog001-error.log
#用户日志
CustomLog "logs/tblog001-access.log" common
#下面为目录权限配置信息,可以省略
<Directory "d:/wamp/www/blog">
Options Indexes FollowSymLinks
#AllowOverride None
# modify @2015-09-19
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

4,)配置host(C:\Windows\System32\drivers\etc\host文件最后一行回车,添加如下一行),保存。

127.0.0.1       www.tblog001.com

5,)重启wampserver,输入网址(http://www.tblog001.com:8080/)访问:

转载地址:http://vtmpl.baihongyu.com/

你可能感兴趣的文章
业务分析之--权限管理
查看>>
稳健的漫步~~~
查看>>
取得NSDate实例各个字段的数字
查看>>
Laravel 5.2问题-----postman进api的post请求,为什么出现Forbidden?
查看>>
vs2013update4 vs-mda-remote cordova真机测试ios
查看>>
Mangos源码分析(3):服务器结构探讨之简单的世界服实现
查看>>
快手,抖音,美拍打造个人IP精准引流!
查看>>
2015年最新数据库流行排行榜
查看>>
企业Java应用服务器之JBoss7.1与Apahce整合
查看>>
临时数据库之python用sqlite3模块操作sqlite
查看>>
苏宁开启“易购”时代,智慧零售、***零售、新零售乱战江湖
查看>>
理解矩阵 [转]
查看>>
css控制的个性导航栏
查看>>
C#_卸载快捷方式添加(转)
查看>>
半解TextBox灵异事件背后神秘的深度灵异事件
查看>>
Defense hash algorithm collision 防御hash算法冲突导致拒绝服务器
查看>>
cocos2d 入门必备4个基本概念
查看>>
vim配置
查看>>
布局xml 转 view
查看>>
Boghe连接FreeSwitch的配置
查看>>