Web 服务器也称为 WWW 服务器或 HTTP 服务器 (HTTP Server),它是 Internet 上最常见也是使用最频繁的服务器之一,Web 服务器能够为用户提供网页浏览、论坛访问等等服务。
由于用户在通过 Web 浏览器访问信息资源的过程中,无须再关心一些技术性的细节,而且界面非常友好,因而 Web 在 Internet 上一推出就得到了爆炸性的发展。现在 Web 服务器已经成为 Internet 上最大的计算机群,Web 文档之多、链接的网络之广,也令人难以想像。因此,Web 服务器软件的数量也开始增加,Web 服务器软件市场的竞争也越来越激烈。本文所讨论的就是一款最常用的 Web 服务器软件—— Apache。
Apache 是一个免费的软件,用户可以免费从 Apache 的官方网站下载。任何人都可以参加其组成部分的开发。Apache 允许世界各地的人对其提供新特性。当新代码提交到 Apache Group 后,Apache Group 对其具体内容进行审查并测试和质量检查。如果他们满意,该代码就会被集成到 Apache 的主要发行版本中。
图 1 和图 2 为安全设定这两个选项前后正常情况下和错误情况下的输出页面(通过 Rhel5 中的 Mozilla Firefox 浏览器访问 Rhel5 中的 Apache 服务器)的详细对比。可以清楚看到,安全设定选项后,可以充分地向客户端用户隐藏 Linux 操作系统信息和 Apache 服务器版本信息。
图 1. 错误情况下未设定安全选项前示意
iimage001
图 2. 操作情况下使用安全设定后的对比
iimage002
设置虚拟目录和目录权限
要从主目录以外的其他目录中进行发布,就必须创建虚拟目录。虚拟目录是一个位于 Apache 的主目录外的目录,它不包含在 Apache 的主目录中,但在访问 Web 站点的用户看来,它与位于主目录中的子目录是一样的。每个虚拟目录都有一个别名,用户 Web 浏览器中可以通过此别名来访问虚拟目录,如 http:// 服务器 IP 地址 / 别名 / 文件名,就可以访问虚拟目录下面的任何文件了。
使用 Alias 选项可以创建虚拟目录。在主配置文件中,Apache 默认已经创建了两个虚拟目录。这两条语句分别建立了“/icons/”和“/manual”两个虚拟目录,它们对应的物理路径分别是“/var/www/icons/”和“/var/www/manual”。在主配置文件中,用户可以看到如下配置语句:
# openssl genrsa -out apache.key 1024
Generating RSA private key, 1024 bit long modulus
..........................................++++++
.....................++++++
e is 65537 (0x10001)
# openssl req -new -key apache.key -out apache.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:CN
State or Province Name (full name) [Berkshire]:China
Locality Name (eg, city) [Newbury]:Beijing
Organization Name (eg, company) [My Company Ltd]:CSO
Organizational Unit Name (eg, section) []:CSO
Common Name (eg, your name or your server's hostname) []:localhost
Email Address []:CSO@ittf.org.cn
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:apacheserver
An optional company name []:apacheserver
//
// The location and format of the access logfile(Common Logfile Format).
// If you do not define any access logfiles within a
// container, they will be logged here. Contrariwise, if you *do*
// define per- access logfiles, transactions will be
// logged therein and *not* in this file.
//
CustomLog logs/access_log common