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

步骤、方法:

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

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

  1. #LoadModule vhost_alias_module modules/mod_vhost_alias.so
  1. #LoadModule rewrite_module modules/mod_rewrite.so
  1. #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/)访问:

wampserver环境下,apache本地下设置多个域名的更多相关文章

  1. Windwos下Apache的缓存设置

    1.打开httpd.conf,找到以下几个Module并将其启用(如果没有,可以自行添加)              mod_proxy.so(module_proxy)              m ...

  2. Win7环境下Apache+mod_wsgi本地部署Django

    django基础已经掌握的同学可以尝试将项目发布已寻找些许成就感,以鼓励自己接下来进行django的进阶学习 以前你总是使用python manage.py runserver进行服务启动,但是却不知 ...

  3. Windows下Apache应用环境塔建安全设置(目录权限设置)

    目的:为Apache,php配置受限制的用户权限.保护系统安全.需要的朋友可以参考下. 环境配置情况: apache安装目录:d:\www-s\apache php目录:d:\www-s\php5 m ...

  4. windows下apache+https环境配置

    windows下apache+https环境配置 转 https://www.cnblogs.com/sandaizi/p/7519370.html 1.修改配置文件conf/httpd.conf,去 ...

  5. PHP在Linux下Apache环境中执行exec,system,passthru等服务器命令函数

    更多内容推荐微信公众号,欢迎关注: 若在服务器中使用php test.php运行exec,system,passthru等命令相关的脚本能成功运行,在web页面却没反应, [可能是服务器端,PHP脚本 ...

  6. windows 下 apache设置

    apache,apache配置,配置端口 mac下apache配置 添加虚拟主机: Alias /selftest/ "D:/self-test/" <Directory & ...

  7. windows server2008服务器下XAMPP集成环境配置apache的SSL证书:

    1.在腾讯与申请的免费SSL证书.按其要求配置,并提交申请,进行审核,审核通过,获得一年使用的SSL免费证书. 2.按下面的要求,进行SSL证书安装配置.本人在配置XAMPP下的apache时,无需复 ...

  8. Ubuntu下Apache+SVN+submin实现WEB管理SVN

    为什么需要submin管理SVN? 原来在Ubuntu下,都是直接通过命令行创建SVN仓库并分配权限,但是这有一些问题: 每创建一个SVN仓库,都需要修改httpd.conf 每创建一个帐户,都需要手 ...

  9. windows下 apache 二级域名相关配置

    小编今天给大家总结下 windows 下 apache的二级域名的相关配置 利用.htaccess将域名绑定到子目录 下面就利用本地127.0.0.1进行测试 我们这里以 www.jobs.com 为 ...

随机推荐

  1. boolalpha

    /* 功能: 把bool值显示为true或false */ #include<iostream> using namespace std; int main() { char str1[] ...

  2. android Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine.

    在当前工程目录中 gradle.properties 添加org.gradle.jvmargs=-XX\:MaxHeapSize\=256m -Xmx256m http://stackoverflow ...

  3. 利用js轻松实现页面简繁体转换

    使用方法:StranBody(); //转换对象,使用递归,逐层剥到文本 function StranBody(fobj) { if(typeof(fobj)=="object") ...

  4. 版本python2和版本3.X的一个区别之一

    print函数 虽然print语法是Python 3中一个很小的改动,且应该已经广为人知,但依然值得提一下:Python 2中的print语句被Python 3中的print()函数取代,这意味着在P ...

  5. LMAO?

    70 weeks to finish TC problems? 2015.4.16 week1 week1~week8:Graph 1.DFS,BFS,Topological sort,Strongl ...

  6. 用Java操作树莓派!pi4j简介与安装

    简介 对C不熟?习惯了使用java不想换语言,但又想操作树莓派?想一边喝咖啡,一边吃树莓派蛋糕?快来使用pi4j吧! pi4j旨在为java开发者提供面友好的面向对象的API,来操控树莓派.pi4j对 ...

  7. python 之 推导式

    推导式 : 英文 comprehension 支持推导式的有列表list      字典dict      集合set      注意元组没有 推导式,如果你那样去写,他会变成一个generator生 ...

  8. QTextCodec::makeDecoder函数,plugins需要是动态链接库

    QT中的QString内容使用Unicode作为文本编码.但是实际系统中通常采用的是其他编码,例如GBK,utf8等.为了便于兼容这些格式,QT中还设置了两个字符串类型: QCString类: C类型 ...

  9. PHP 日期比较

    $temptime = mktime(8,2,12,4,4,2014);$dt1 = date("Y-m-d",time());$dt2 = date("Y-m-d&qu ...

  10. Effective Project Communications

    I was recently invited to speak at a conference in Singapore on Effective Project Communications. I' ...