学习热线

用实验快速掌握web服务器Apache           ★★★
用实验快速掌握web服务器Apache
学习热线网:http://www.xx988.com    来源:Linuxeden.com    点击数:    更新时间:2005-5-23

    Apache是大多数linux版本的标准web 服务器,掌握他的意义就非常大。

    本文以实验的方式,让读者快速掌握Apache的基本配置。   

   [实验目的]

   1.Apache的基本安装和配置。

   2.Apache中应用CGI。

   3.基本代理配置。

   [实验要求]

   1.两台互通的RH8.0机。

   2.这两台机已配置过DNS。

   [实验步骤]

   1.准备工作。

   由于web 服务器与DNS关系非常紧密。作好这步准备工作,请参考本人的另一篇文章“用实验快速掌握DNS配置”。这篇文章发表在linuxsir的网络版块。

   DNS 能够实现的主要功能就是能能解析:station1.exmaple1.com,server1.example1.com 两个域名的IP,如果你想在/etc/hosts中实现,我想也不是不可以。这里不提倡这么做。

   本文中作法比较教条,这里指明机器1为:server1.example1.com,机器2为:

   station1.example1.com .读者也可以自己变通。


   2.在机器1上安装和配置简单的Apache。

   1) 检查下列包是否安装,

   httpd

   httpd-manual

   缺什么,装什么。

   2) 开启httpd服务

   # service httpd start

   如果开启失败,查看/var/log/httpd/下的相关日志,切记要在/etc/hosts中添加类似

   192.168.0.254 example1.com server1 的一行。

   3) 检查/etc/httpd/conf/httpd.conf中,有下列一行活动

   DocumentRoot /var/www/html

   4) 用一个浏览器打开:

   http://server1.example1.com

   如果是正常情况,你会看到Apache的介绍页面。

   5) 创建新的目录和html文件。

   # mkdir -p /var/www/virtual/server1.example1.com/html

   # vi /var/www/virtual/server1.example1.com/html/index.html

   Server1.example1.com

   6) 编辑/etc/httpd/conf/httpd.conf,末尾追加下列文本。

   NameVirtualHost 192.168.0.254    

   ServerName server1.example1.com

   ServerAdmin root@server1.example1.com

   DocumentRoot /var/www/virtual/server1.example1.com/html

   ErrorLog logs/server1.example1.com-error_log

   CustomLog logs/server1.example1.com-access_log combined   

   Options Indexes Includes

   7) 确保DNS能够解析你的VirtualHost

   # host server1.example1.com

   8) 重新启动httpd

   # service httpd restart

   如果启动失败,看/var/log/httpd/下的相应日志,会告诉你具体哪里错误。

   9) 在浏览器里能够看到你自己写的网页了吗?

   http://server1.example1.com

[1] [2] 下一页  

  • 上一篇文章: 解读Linux文件权限的设置方法

  • 下一篇文章: 红旗linux认证工程师考题回放