⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mass.html.en

📁 apache的软件linux版本
💻 EN
📖 第 1 页 / 共 2 页
字号:
    <code>&lt;VirtualHost&gt;</code> configuration sections.</p><div class="example"><p><code>UseCanonicalName Off<br /><br />LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon<br /><br />&lt;Directory /www/commercial&gt;<br /><span class="indent">    Options FollowSymLinks<br />    AllowOverride All<br /></span>&lt;/Directory&gt;<br /><br />&lt;Directory /www/homepages&gt;<br /><span class="indent">    Options FollowSymLinks<br />    AllowOverride None<br /></span>&lt;/Directory&gt;<br /><br />&lt;VirtualHost 111.22.33.44&gt;<br /><span class="indent">    ServerName www.commercial.isp.com<br />    <br />    CustomLog logs/access_log.commercial vcommon<br />    <br />    VirtualDocumentRoot /www/commercial/%0/docs<br />    VirtualScriptAlias  /www/commercial/%0/cgi-bin<br /></span>&lt;/VirtualHost&gt;<br /><br />&lt;VirtualHost 111.22.33.45&gt;<br /><span class="indent">    ServerName www.homepages.isp.com<br />    <br />    CustomLog logs/access_log.homepages vcommon<br />    <br />    VirtualDocumentRoot /www/homepages/%0/docs<br />    ScriptAlias         /cgi-bin/ /www/std-cgi/<br /></span>&lt;/VirtualHost&gt;</code></p></div></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="ipbased" id="ipbased">More Efficient IP-Based Virtual Hosting</a></h2>    <p>The configuration changes suggested to turn <a href="#simple">the first    example</a> into an IP-based virtual hosting setup result in    a rather inefficient setup. A new DNS lookup is required for every    request. To avoid this overhead, the filesystem can be arranged to    correspond to the IP addresses, instead of to the host names, thereby    negating the need for a DNS lookup. Logging will also have to be adjusted    to fit this system.</p><div class="example"><p><code># get the server name from the reverse DNS of the IP address<br />UseCanonicalName DNS<br /><br /># include the IP address in the logs so they may be split<br />LogFormat "%A %h %l %u %t \"%r\" %s %b" vcommon<br />CustomLog logs/access_log vcommon<br /><br /># include the IP address in the filenames<br />VirtualDocumentRootIP /www/hosts/%0/docs<br />VirtualScriptAliasIP  /www/hosts/%0/cgi-bin<br /></code></p></div></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="simple.rewrite" id="simple.rewrite">Simple Dynamic    Virtual Hosts Using <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code></a></h2>    <p>This extract from <code>httpd.conf</code> does the same    thing as <a href="#simple">the first example</a>. The first    half is very similar to the corresponding part above, except for    some changes, required for backward compatibility and to make the    <code>mod_rewrite</code> part work properly; the second half    configures <code>mod_rewrite</code> to do the actual work.</p>    <p>There are a couple of especially tricky bits: by default,    <code>mod_rewrite</code> runs before other URI translation    modules (<code>mod_alias</code> etc.) - so if you wish to use these modules,    <code>mod_rewrite</code> must be configured to accommodate    them. Also, some magic is required to do a    per-dynamic-virtual-host equivalent of    <code>ScriptAlias</code>.</p><div class="example"><p><code># get the server name from the Host: header<br />UseCanonicalName Off<br /><br /># splittable logs<br />LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon<br />CustomLog logs/access_log vcommon<br /><br />&lt;Directory /www/hosts&gt;<br /><span class="indent">    # ExecCGI is needed here because we can't force<br />    # CGI execution in the way that ScriptAlias does<br />    Options FollowSymLinks ExecCGI<br /></span>&lt;/Directory&gt;<br /><br /># now for the hard bit<br /><br />RewriteEngine On<br /><br /># a ServerName derived from a Host: header may be any case at all<br />RewriteMap  lowercase  int:tolower<br /><br />## deal with normal documents first:<br /># allow Alias /icons/ to work - repeat for other aliases<br />RewriteCond  %{REQUEST_URI}  !^/icons/<br /># allow CGIs to work<br />RewriteCond  %{REQUEST_URI}  !^/cgi-bin/<br /># do the magic<br />RewriteRule  ^/(.*)$  /www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1<br /><br />## and now deal with CGIs - we have to force a MIME type<br />RewriteCond  %{REQUEST_URI}  ^/cgi-bin/<br />RewriteRule  ^/(.*)$  /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1  [T=application/x-httpd-cgi]<br /><br /># that's it!</code></p></div></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="homepages.rewrite" id="homepages.rewrite">A    Homepages System Using <code>mod_rewrite</code></a></h2>    <p>This does the same thing as <a href="#homepages">the second    example</a>.</p><div class="example"><p><code>RewriteEngine on<br /><br />RewriteMap   lowercase  int:tolower<br /><br /># allow CGIs to work<br />RewriteCond  %{REQUEST_URI}  !^/cgi-bin/<br /><br /># check the hostname is right so that the RewriteRule works<br />RewriteCond  ${lowercase:%{SERVER_NAME}}  ^www\.[a-z-]+\.isp\.com$<br /><br /># concatenate the virtual host name onto the start of the URI<br /># the [C] means do the next rewrite on the result of this one<br />RewriteRule  ^(.+)  ${lowercase:%{SERVER_NAME}}$1  [C]<br /><br /># now create the real file name<br />RewriteRule  ^www\.([a-z-]+)\.isp\.com/(.*) /home/$1/$2<br /><br /># define the global CGI directory<br />ScriptAlias  /cgi-bin/  /www/std-cgi/</code></p></div></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="xtra-conf" id="xtra-conf">Using a Separate Virtual    Host Configuration File</a></h2>    <p>This arrangement uses more advanced <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>    features to work out the translation from virtual host to document    root, from a separate configuration file. This provides more    flexibility, but requires more complicated configuration.</p>    <p>The <code>vhost.map</code> file should look something like    this:</p><div class="example"><p><code>www.customer-1.com  /www/customers/1<br />www.customer-2.com  /www/customers/2<br /># ...<br />www.customer-N.com  /www/customers/N<br /></code></p></div>    <p>The <code>httpd.conf</code> should contain the following:</p><div class="example"><p><code>RewriteEngine on<br /><br />RewriteMap   lowercase  int:tolower<br /><br /># define the map file<br />RewriteMap   vhost      txt:/www/conf/vhost.map<br /><br /># deal with aliases as above<br />RewriteCond  %{REQUEST_URI}               !^/icons/<br />RewriteCond  %{REQUEST_URI}               !^/cgi-bin/<br />RewriteCond  ${lowercase:%{SERVER_NAME}}  ^(.+)$<br /># this does the file-based remap<br />RewriteCond  ${vhost:%1}                  ^(/.*)$<br />RewriteRule  ^/(.*)$                      %1/docs/$1<br /><br />RewriteCond  %{REQUEST_URI}               ^/cgi-bin/<br />RewriteCond  ${lowercase:%{SERVER_NAME}}  ^(.+)$<br />RewriteCond  ${vhost:%1}                  ^(/.*)$<br />RewriteRule  ^/(.*)$                      %1/cgi-bin/$1 [T=application/x-httpd-cgi]</code></p></div></div></div><div class="bottomlang"><p><span>Available Languages: </span><a href="../en/vhosts/mass.html" title="English">&nbsp;en&nbsp;</a> |<a href="../ko/vhosts/mass.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p></div><div id="footer"><p class="apache">Copyright 2007 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p><p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -