📄 ahttp.txt
字号:
APACHE
An HTTP Server
Reference Manual
@ David Robinson and the Apache Group, 1995
http://www.apache.org/
保留所有权利。这个产品或文件受版权保护并且得在限制其用途,复制
,散播以及编辑的授权下散播。细节请参阅阿帕契授权书。
版权所有者不对这份手册的内容作任何保证及建议而且特别声明不保证
符合任何商业目的。
版权所有者保留修订这份手册的权利且其内容得依时变更而不必通知任
何人这些修订与变更。
All rights reserved. This product or documentation protected by
copyright
and is distributed under licences restricting its use,
copying,
distribution and decompilation. See the Apache licence for details.
The copyright owner gives no warranties and makes no representations
about
the contents of this manual and specifically disclaims
warranties of
merchantability of fitness for any purpose.
The Copyright owner reserves the right to revise this manual and
make
changes from time to time in its contents without notifying any
person of
such revision or changes.
TRADEMARKS
Unix is a registered trademark of UNIX System Laboratories, Inc.
Sun and
SunOs are trademarks of Sun Microsystems, Inc. Netscape is a
trademark of
Netscape Communications Corporation. All other product names
mentioned
herein are trademarks of their respective owners.
目录(Contents) (略)
序(Preface)
这份手册是 1.0 版阿帕契伺服器(Apache HTTP server)的文件。这个
伺服器是阿帕契计画的产品,此计画试图回应某些对积极发展一套可以
免费取得之 HTTP 伺服器的关心。这个计画的目标是提供一个安全的,
有效率的而且可以扩充功能的伺服器,此伺服器提供 HTTP 服务且符合
目前的 HTTP 标准。
这套阿帕契 httpd 伺服器的设计不但与 NCSA httpd 1.3 相容,并且
提供常常有人要求的特色,像是
。作为身分验认之用的 DBM 资料库
。自定的(customised)错误与问题回应方式
。多重的 directoryindex 指令
。不限次数的 Alias 以及 Redirect 指令
。以内容为基础的(Content-based) 文件协商(negotiation)
。虚拟伺服器
阿帕契授权书
Copyright 1995 The Apache Group. All rights reserved.
假若符合下列条件,无论是否经过修改,以原始程式及执行程式的形式
散播与使用都是许可的:
1. 散播原始程式码必须保留上述的版权告示,这份条件列表以及下列
声明。
2. 以执行程式码的形式散播必须在随附散播的文件以及/或是资讯中
重现上述的版权告示,这份条件列表以及下列声明。
3. 所有提及或使用这套软体特色的广告都必须显示下列讯息:
`This product includes software developed by the Apache Group
for
use in the Apache HTTP server project
(http://www.apache.org/).'
4. `Apache Server' 以及 `Apache Group' 这些名称没有随附前述的
的许可不得用来为这套软体的衍生产品背书或鼓励采用。
5. 以任何形式散播都必须保留下列讯息:
`This product includes software developed by the Apache Group
for
use in the Apache HTTP server project
(http://www.apache.org/).'
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following condictions
are met:
1. Redistribution of source code must retain the above copyright
notice, this list of condictions and the following disclaimer.
2. Redistribution in binary form must reproduce the above copyright
notice, this list of condictions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. All advertising materials mentioning features or use of this
software must display the following acknowledge: `This product
includes software developed by the Apache Group for use in the
Apache HTTP server project (http://www.apache.org/).'
4. The names `Apache Server' and `Apache Group' must not be used to
endorse or prompt products derived from this software without
prior written permission.
5. Redistribution of any form whatsoever must retain the following
acknowledge: `This product includes software developed by the
Apache Group for use in the Apache HTTP server project
(http://www.apache.org/).'
THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
EXPRESSED OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARITICULAR PURPOSE ARE
DISCLAIMED. IN NO
EVENT SHALL THE APACHE GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY
DIRECT,
INDIRECT, INCIDETAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES
(INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS
OF USE,
DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY
OF LIABILITY, WHERHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING
NEGLIGENCE OR OTHER WISE)ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many
individuals
on behalf of the Apache Group and was originally based on
public domain
software written at the National Center for Supercomputing
Applications,
University of Illinois, Urbana-Champaign. For more information on
the apache
Group and the Apache HTTP server project, please see
http://www.apache.org/.
第一章
编译以及安装阿帕契
1.1 下载阿帕契
最新的阿帕契资讯可以在阿帕契网站 http://www.apache.org/ 找到。
此处会列出目前发行的版本,任何更新的公开测试版,同时还有映射的
(mirror)网站与匿名档案传输(ftp) 站之细节。
1.2 编译阿帕契
这一版的阿帕契支援所谓的‘选用性模组’。然而,为了使这些模组能
有效率,此伺服器必须知道哪些模组要编译进去;这需要产生一点短短
的程式码(`modules.c') 单纯地列出它们。
如果你满意我们的标准模组集,而且打算继续让它保持这样,那麽你可
以直接编辑我们提供的 Makefile 并且如同你以前作过的一样编译它。
如果你想要使用选用性模组,那麽无论如何,你都得执行配置指令稿。
这样做:
1. 编辑 `Configuration' 这个档案。这里面包含每一种机器
的 Makefile 设定,而且在这底下还有个额外的节区列出要
编译进去的模组,以及包含这些模组的档案名称,你将得:
(a) 选择适合你机器的一种编译器以及编译选项。
(b) 消掉相对於你想包含进去的模组上面的注解(档案底
端列出模组的那些行)或者加上对应你自己所撰写之
自制(custom)模组的一些新行。注意,如果你想要有
DBM 验认(auth)的话必须明确地配置进去;只要消掉
对应的行上面的注解即可。
2. 执行 `Configure' 这个指令稿:
% Configure
Using `Configuration' as config file
%
这会产生新版的 Makefile 以及 modules.c 档案。如果你
想要维护多个配置,那麽你可以这样,例如
% Configure -file Configuration.ai
Using alternate config file Configuration.ai
%
3. 键入 `make'
我们放进阿帕契发行套件里的模组是我们测试过而且有许多
阿帕契发展群成员使用的模组。这些成员或协力团体(third
parties)配合特殊需要或功能而贡献的一些额外模组可以在
里
找到。在该网页上有如何连结这些模组到阿帕契核心程式码
里去的说明。
1.3 安装阿帕契
编译之後,你将会在 src/ 目录里获得一份称为 `httpd' 的执行码。
阿帕契的执行码发行套件会提供这个档案。
下一个步骤是为伺服器编辑配置档。你应该会在称为 `conf' 的目录里
发现三个配置档的发行版本: srm.conf-dist, access.conf-dist 以及
httpd.conf-dist 。把它们复制成所需的 srm.conf, access.conf 及
httpd.conf 档案。
首先编辑 httpd.conf 。这设定此伺服器一般的属性;埠号,执行者的
身分等等。接下来编辑 srm.conf 档案;这设定文件树的根,指定像是
伺服端剖析的 HTML 或内部的影像地图(imagemap)剖析等等功能。最後
编辑 access.conf 档案,至少作些存取(access)的基本设定。
最後,呼叫 httpd 程式,使用 -f 参数配合 httpd.conf 所在的完整
路径。像是,最普遍的例子:
/usr/local/etc/apache/src/httpd -f
/usr/local/etc/apache/conf/httpd.conf
现在伺服器应该已经开始执行。
依照预设 srm.conf 以及 access.conf 这些档案是藉由名称定位的;
要藉由其它的名称来指定呼叫它们的话,可以在 httpd.conf 里面使用
AccessConfig 以及 ResourceConfig 指令。
第二章
启动阿帕契
2.1 启动阿帕契
httpd 这支程式可以藉由网际网路伺服程式 inetd 在每一次有连线要
进入 HTTP 服务的时候启动,或者另一种方式,它也可以作为伺服程式
(daemon)持续地执行,处理请求。无论选择哪一种方式,都必须设定这
个 ServerType 指令告诉伺服器它要如何执行。
2.2 命令列选项
下列选项可以用在 httpd 的命令列上:
-d serverroot
把 ServerRoot 这个变数的起始值设定为 serverroot 。这可以
藉由在配置档案里面的 ServerRoot 命令来加以改变。此预设为
/usr/local/etc/httpd 。
-f config
启动时执行在 config 档案里面的指令。如果 config 没有以 /
作为开始的话,那麽它会被当作相对於 ServerRoot 的路径。此
预设值是 conf/httpd.conf 。
-X
以单一程序(single-process)模式执行,只用在内部除错;伺服
程式不会脱离终端作业或是产生任何子程序。不要使用这个模式
来提供正常的网页服务。
-v
列印 httpd 的版本,然後结束。
-?
列印 httpd 选项的一份列表,然後结束。
2.3 配置档
此伺服器将会读取三个配置指令档案。任何指令都可以出现在这些档案
任何一个里面。这些档案的名称是相对於伺服器的根(server root) ;
这是根是藉由 ServerRoot 指令,或是 -d 这个命令列旗标所指定的。
依惯例这些档案是:
conf/httpd.conf
包含控制伺服程式运作的指令。档案名称可以配合 -f 命令列旗
旗标加以改变。
conf/srm.conf
包含控制伺服器提供给客户端之文件规格的指令。档案名称可以
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -