<!DOCTYPE html SYSTEM "about:legacy-compat">
<html lang="zh-cn"><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="width=device-width, initial-scale=1" name="viewport">
<!--
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
              This file is generated from xml source: DO NOT EDIT
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
      -->
<title>Apache 虚拟主机文档 - Apache HTTP 服务器 版本 2.4</title>
<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet">
<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size">
<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css"><link rel="stylesheet" type="text/css" href="../style/css/prettify.css">
<script src="../style/scripts/prettify.min.js">
</script>

<link href="../images/favicon.png" rel="shortcut icon"></head>
<body id="manual-page"><div id="page-header">
<p class="menu"><a href="../mod/">模块</a> | <a href="../mod/quickreference.html">指令</a> | <a href="https://cwiki.apache.org/confluence/display/httpd/FAQ">常见问题</a> | <a href="../glossary.html">术语</a> | <a href="../sitemap.html">网站导航</a> | <a href="https://bz.apache.org/bugzilla/enter_bug.cgi?product=Apache%20httpd-2">Report a bug</a></p>
<p class="apache">Apache HTTP 服务器版本 2.4</p>
<img alt="" src="../images/feather.png"></div>
<div class="up"><a href="../"><img title="<-" alt="<-" src="../images/left.gif"></a></div>
<div id="path">
<a href="https://www.apache.org/">Apache</a> &gt; <a href="https://httpd.apache.org/">HTTP 服务器</a> &gt; <a href="https://httpd.apache.org/docs/">文档</a> &gt; <a href="../">版本 2.4</a></div><div id="page-content"><div id="preamble"><h1>Apache 虚拟主机文档</h1>
<button aria-label="Toggle language list" class="lang-toggle"><svg xmlns="http://www.w3.org/2000/svg" stroke-width="2" stroke="currentColor" fill="none" viewBox="0 0 24 24" height="16" width="16"><circle r="10" cy="12" cx="12"/><line y2="12" x2="22" y1="12" x1="2"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg></button>
<div class="toplang">
<p><span>可用语言: </span><a href="../de/vhosts/" hreflang="de" rel="alternate" title="Deutsch">&nbsp;de&nbsp;</a> |
<a href="../en/vhosts/" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
<a href="../fr/vhosts/" hreflang="fr" rel="alternate" title="Fran&ccedil;ais">&nbsp;fr&nbsp;</a> |
<a href="../ja/vhosts/" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="../ko/vhosts/" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
<a href="../tr/vhosts/" hreflang="tr" rel="alternate" title="T&uuml;rk&ccedil;e">&nbsp;tr&nbsp;</a> |
<a href="../zh-cn/vhosts/" title="Simplified Chinese">&nbsp;zh-cn&nbsp;</a></p>
</div>
<div class="outofdate">此翻译可能过期。要了解最近的更改，请阅读英文版。</div>


    <p>术语<cite>虚拟主机</cite>指的是在单一机器上运行多个网站
    (例如 <code>company1.example.com</code> 和
    <code>company2.example.com</code>) 。
    虚拟主机可以"<a href="ip-based.html">基于 IP</a>"，即每个 IP 一个站点；
    或者"<a href="name-based.html">基于名称</a>"，
    即每个 IP 多个站点。这些站点运行在同一物理服务器上的事实不会明显的透漏给最终用户。</p>

    <p>Apache 是第一个支持基于 IP 的虚拟主机的服务器。
    Apache 版本 1.1 和更新的版本同时支持基于 IP 和基于名称的虚拟主机。
    基于名称的虚拟主机有时候称为<em>基于主机</em>或<em>非 IP</em> 的虚拟主机.</p>

    <p>以下解释是在 Apache 中支持虚拟主机的所有详细信息的文档页面列表。</p>

</div>
<div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif"> <a href="#support">虚拟主机支持</a></li>
<li><img alt="" src="../images/down.gif"> <a href="#directives">配置指令</a></li>
</ul><h3>参见</h3><ul class="seealso"><li><code class="module"><a href="../mod/mod_vhost_alias.html">mod_vhost_alias</a></code></li><li><a href="name-based.html">基于名称的虚拟主机</a></li><li><a href="ip-based.html">基于 IP 的虚拟主机</a></li><li><a href="examples.html">虚拟主机样例</a></li><li><a href="fd-limits.html">文件句柄限制</a></li><li><a href="mass.html">动态配置的大规模虚拟主机</a></li><li><a href="details.html">虚拟主机匹配的深入讨论</a></li></ul></div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif"></a></div>
<div class="section">
<h2 id="support">虚拟主机支持 <a title="Permanent link" href="#support" class="permalink">&para;</a></h2>

    <ul>
      <li><a href="name-based.html">基于名称的虚拟主机</a> (每个 IP 多个站点)</li>
      <li><a href="ip-based.html">基于 IP 的虚拟主机</a> (每个 IP 一个站点)</li>
      <li><a href="examples.html">虚拟主机样例</a></li>
      <li><a href="fd-limits.html">文件句柄限制</a> (或者<em>日志文件太多</em>)</li>
      <li><a href="mass.html">动态配置的大规模虚拟主机</a></li>
      <li><a href="details.html">虚拟主机匹配的深入讨论</a></li>
    </ul>

</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif"></a></div>
<div class="section">
<h2 id="directives">配置指令 <a title="Permanent link" href="#directives" class="permalink">&para;</a></h2>

    <ul>
      <li><code class="directive"><a href="../mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code></li>
      <li><code class="directive"><a href="../mod/core.html#servername">ServerName</a></code></li>
      <li><code class="directive"><a href="../mod/core.html#serveralias">ServerAlias</a></code></li>
      <li><code class="directive"><a href="../mod/core.html#serverpath">ServerPath</a></code></li>
    </ul>

    <p>如果你要调试虚拟主机配置，你会发现 Apache 的命令行参数 <code>-S</code>
    非常有用。即输入以下命令:</p>

    <div class="example"><p><code>
    /usr/local/apache2/bin/httpd -S
    </code></p></div>

    <p>这个命令将会显示 Apache 是如何解析配置文件的。仔细检查 IP
    地址与服务器名称可能会帮助你发现配置错误
    (参见 <code class="program"><a href="../programs/httpd.html">httpd</a></code> 程序文档，以便了解其它命令行选项)。</p>

</div></div>
<div class="bottomlang">
<p><span>可用语言: </span><a href="../de/vhosts/" hreflang="de" rel="alternate" title="Deutsch">&nbsp;de&nbsp;</a> |
<a href="../en/vhosts/" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
<a href="../fr/vhosts/" hreflang="fr" rel="alternate" title="Fran&ccedil;ais">&nbsp;fr&nbsp;</a> |
<a href="../ja/vhosts/" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="../ko/vhosts/" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
<a href="../tr/vhosts/" hreflang="tr" rel="alternate" title="T&uuml;rk&ccedil;e">&nbsp;tr&nbsp;</a> |
<a href="../zh-cn/vhosts/" title="Simplified Chinese">&nbsp;zh-cn&nbsp;</a></p>
</div><div id="footer">
<p class="apache">Copyright 2026 The Apache Software Foundation.<br>基于 <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> 许可证.</p>
<p class="menu"><a href="../mod/">模块</a> | <a href="../mod/quickreference.html">指令</a> | <a href="https://cwiki.apache.org/confluence/display/httpd/FAQ">常见问题</a> | <a href="../glossary.html">术语</a> | <a href="../sitemap.html">网站导航</a> | <a href="https://bz.apache.org/bugzilla/enter_bug.cgi?product=Apache%20httpd-2">Report a bug</a></p></div><script><!--//--><![CDATA[//><!--
if (typeof(prettyPrint) !== 'undefined') {
    prettyPrint();
}
var langToggle = document.querySelector('.lang-toggle');
var topLang = document.querySelector('.toplang');
if (langToggle && topLang) {
    langToggle.addEventListener('click', function() { topLang.classList.toggle('open'); });
}
var qv = document.getElementById('quickview');
if (qv) {
    document.body.appendChild(qv);
    var qvBtn = document.createElement('button');
    qvBtn.className = 'qv-toggle';
    qvBtn.setAttribute('aria-label', 'Toggle page navigation');
    qvBtn.innerHTML = '&#9776;';
    document.body.appendChild(qvBtn);
    qvBtn.addEventListener('click', function() {
        var isOpen = qv.classList.toggle('open');
        if (isOpen) {
            qv.style.top = window.scrollY + 10 + 'px';
        }
    });
    window.addEventListener('scroll', function() { qv.classList.remove('open'); });
}
//--><!]]></script>
</body></html>