在windows环境下,apache从配置文件的相关配置:
Windows 是市场占有率最高的 PC 操作系统, 也是很多人的开发环境. 其 VirtualHost 配置方法与 Linux 上有些差异, 以下方式适合原生 Apache, XAMPP 和 WAMP 套件.
1. 打开目录 {Apache2 安装目录}\conf\extra\, 找到 httpd-vhosts.conf 文件.
2. 仿照例子, 添加一段代码来指定某一域名的网站.
 
 
#
# DocumentRoot 是网站文件存放的根目录
# ServerName 是网站域名, 需要跟 DNS 指向的域名一致
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "D:/workspace/php/demo_neoease_com"
ServerName demo.neoease.com
ErrorLog "logs/demo.neoease.com-error.log"
CustomLog "logs/demo.neoease.com-access.log" common
</VirtualHost>
 
3. 打开 httpd.conf 文件, 添加如下语句.
 
 
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
 
 

怎样配置apache虚拟主

基于不同情况下配置apache虚拟主机的方法,一共八种情况。首先查看你虚拟主机属于哪一种情况,然后对号入座就好了。过程不复杂,关键在于对症下药。

步骤/方法

  1. 1
    基于ip地址的虚拟主机
    Listen 80
    <VirtualHost 172.20.30.40>
    DocumentRoot /home/httpd/html1
    ServerName www.ok1.com
    ErrorLog /usr/local/apache/logs/error1_log
    CustomLog /usr/local/apache/logs/access1_log combined
    </VirtualHost>
    <VirtualHost 172.20.30.50>
    DocumentRoot /home/httpd/html2
    ServerName www.ok2.com
    ErrorLog /usr/local/apache/logs/error2_log
    CustomLog /usr/local/apache/logs/access2_log combined
    </VirtualHost>
  2. 2
    基于IP 和多端口的虚拟主机配置
    Listen 172.20.30.40:80
    Listen 172.20.30.40:8080
    Listen 172.20.30.50:80
    Listen 172.20.30.50:8080
    <VirtualHost 172.20.30.40:80>
    DocumentRoot /www/example1-80
    ServerName www.example1.com
    </VirtualHost>
    <VirtualHost 172.20.30.40:8080>
    DocumentRoot /www/example1-8080
    ServerName www.example1.com
    </VirtualHost>
    <VirtualHost 172.20.30.50:80>
    DocumentRoot /www/example2-80
    ServerName www.example1.org
    </VirtualHost>
    <VirtualHost 172.20.30.50:8080>
    DocumentRoot /www/example2-8080
    ServerName www.example2.org
    </VirtualHost>
  3. 3
    单个IP 地址的服务器上基于域名的虚拟主机配置
    # Ensure that Apache listens on port 80
    Listen 80
    # Listen for virtual host requests on all IP addresses
    NameVirtualHost *:80
    <VirtualHost *:80>
    DocumentRoot /www/example1
    ServerName www.example1.com
    ServerAlias example1.com. *.example1.com
    # Other directives here
    </VirtualHost>
    <VirtualHost *:80>
    DocumentRoot /www/example2
    ServerName www.example2.org
    # Other directives here
    </VirtualHost>
  4. 4
    在多个IP 地址的服务器上配置基于域名的虚拟主机
    Listen 80
    # This is the "main" server running on 172.20.30.40
    ServerName server.domain.com
    DocumentRoot /www/mainserver
    # This is the other address
    NameVirtualHost 172.20.30.50
    <VirtualHost 172.20.30.50>
    DocumentRoot /www/example1
    ServerName www.example1.com
    # Other directives here ...
    </VirtualHost>
    <VirtualHost 172.20.30.50>
    DocumentRoot /www/example2
    ServerName www.example2.org
    # Other directives here ...
    </VirtualHost>
  5. 5
    在不同的端口上运行不同的站点(基于多端口的服务器上配置基于域名的虚拟主机)
    Listen 80
    Listen 8080
    NameVirtualHost 172.20.30.40:80
    NameVirtualHost 172.20.30.40:8080
    <VirtualHost 172.20.30.40:80>
    ServerName www.example1.com
    DocumentRoot /www/domain-80
    </VirtualHost>
    <VirtualHost 172.20.30.40:8080>
    ServerName www.example1.com
    DocumentRoot /www/domain-8080
    </VirtualHost>
    <VirtualHost 172.20.30.40:80>
    ServerName www.example2.org
    DocumentRoot /www/otherdomain-80
    </VirtualHost>
    <VirtualHost 172.20.30.40:8080>
    ServerName www.example2.org
    DocumentRoot /www/otherdomain-8080
    </VirtualHost>
  6. 6
    基于域名和基于IP 的混合虚拟主机的配置
    Listen 80
    NameVirtualHost 172.20.30.40
    <VirtualHost 172.20.30.40>
    DocumentRoot /www/example1
    ServerName www.example1.com
    </VirtualHost>
    <VirtualHost 172.20.30.40>
    DocumentRoot /www/example2
    ServerName www.example2.org
    </VirtualHost>
    <VirtualHost 172.20.30.40>
    DocumentRoot /www/example3
    ServerName www.example3.net
    </VirtualHost>

windows环境下,apache虚拟主机配置的更多相关文章

  1. Linux下Apache虚拟主机配置

    Linux下Apache虚拟主机的三种配置.这样可以实现一台主机架构多个独立域名网站.其中基于域名的最为常见.性价比也最高.下面PHP程序员雷雪松详细的讲解下Linux下Apache虚拟主机配置的具体 ...

  2. win 下 apache 虚拟主机配置方式

    虚拟主机的配置在apache安装目录下/conf/extra/httpd-vhosts.conf文件中,需要在/conf/httpd.conf中开启. LoadModule vhost_alias_m ...

  3. CentOS下Apache虚拟主机配置

    通过phpinfo可以看到Apache安装的目录 修改配置文件,首先将配置文件备份 编辑httpd.conf,并找到虚拟路径配置的部分 vi httpd.conf 在vi下先按esc在键入 :/vho ...

  4. apache虚拟主机配置及解析

    Apache虚拟主机配置及解析 1.修改httpd-vhosts.conf 打开apache(Apache24)/conf/extra/httpd-vhosts.conf文件,添加虚拟主机信息,可以这 ...

  5. apache虚拟主机配置HTTPS

    win+apache+php的环境下做虚拟主机的https. 1.https用的是443端口,确定防火墙已经开放443了.2.http.conf要加载以下模块: #这两个是用来存放SSLSession ...

  6. Apache虚拟主机配置

    在一个Apache服务器上可以配置多个虚拟主机,实现一个服务器提供多站点服务,其实就是访问同一个服务器上的不同目录.Apache虚拟主机配置有3中方法:基于IP配置.基于域名配置和基于端口配置,这里介 ...

  7. Apache虚拟主机配置(多个域名访问多个目录)

    Apache虚拟主机配置(多个域名访问多个目录) 为了方便管理虚拟主机,我决定使用一种方法,那就是修改httpd-vhosts.conf文件. 第一步首先要使扩展文件httpd-vhosts.conf ...

  8. Apache虚拟主机配置(多个域名访问多个目录)(转)

    Apache虚拟主机配置(多个域名访问多个目录) 为了方便管理虚拟主机,我决定使用一种方法,那就是修改httpd-vhosts.conf文件. 第一步首先要使扩展文件httpd-vhosts.conf ...

  9. Linux Apache虚拟主机配置方法

    apache 虚拟主机配置 注意: 虚拟主机可以开很多个 虚拟主机配置之后,原来的默认/etc/httpd/httpd.conf中的默认网站就不会生效了 练习: 主机server0 ip:172.25 ...

  10. GITHUB个人博客搭建-Pelican 在Windows环境下的安装及配置

    GITHUB个人博客搭建-Pelican 在Windows环境下的安装及配置 前言 此篇博客主要为Pelican在Windows平台下的配置安装所写,在此过程中主要参考资料烟雨林博客.poem_of_ ...

随机推荐

  1. 动态添加弹出页面(shiro项目中来的七)

    一,图解 二,代码 2.0,新增代码 //打开编辑属性(新增) function dialog_open(){ $("#dialog-add").css("display ...

  2. [JZOJ5522] 图

    题目大意: 一个有向图,图中有\(n\)个点\(m\)条边且无重边无自环, 每秒第\(i\)条边出现的概率是\(\frac{p[i]}{100}\), 一开始\(Samjia\)在\(1\)点,每一秒 ...

  3. 【洛谷T7153】(考试) 中位数

    题目描述 给定 n 个数 a1, a2, ..., an,求这 n 个数两两的差值(共 n(n−1) 2 个)的中位数. 输入格式: 第一行一个正整数 n,表示数的个数. 接下来一行 n 个正整数,分 ...

  4. 【CJOJ2482】【POI2000】促销活动

    题面 Description 促销活动遵守以下规则: 一个消费者 -- 想参加促销活动的消费者,在账单下记下他自己所付的费用,他个人的详细情况,然后将账单放入一个特殊的投票箱. 当每天促销活动结束时, ...

  5. 小结:c++中的new、operator new和placement new

    小结:c++中的new.operator new和placement new new(也称作new operator),是new 操作符,不可重载 class T{...}; T *t = new T ...

  6. js中实现继承的不同方式以及其缺点

    1.利用call和apply,借助构造函数 fucntion P(){ this.name = "P"; } fucntion C1(){ P.call(this); } 解释一下 ...

  7. CSS中image和text显示高度不一致的问题

    将它们分别添加新的属性: float: left 就可以解决

  8. 踩坑系列の Oracle dbms_job简单使用

    二话不说先上代码 --创建存储过程 create or replace procedure job_truncateState is begin --此处就是要定时执行的sql execute imm ...

  9. angular何时触发脏检查机制

    ng只有在指定事件触发后,才进入$digest cycle: DOM事件,譬如用户输入文本,点击按钮等.(ng-click) XHR响应事件 ($http) 浏览器Location变更事件 ($loc ...

  10. 关系型数据库工作原理-事务管理(一)(翻译自Coding-Geek文章)

    本文翻译自Coding-Geek文章:< How does a relational database work>. 原文链接:http://coding-geek.com/how-dat ...