日期:2014-05-16  浏览次数:20649 次

Linux全攻略--Apache服务器配置与管理(一)
一、Apache的安装
首先使用下面的命令来查看系统是否已经安装了Apache
可看到已经安装好了。
另外也可以在终端窗口中执行来查看httpd程序是否在执行。
下面介绍Apache服务器文件和目录
WEB站点目录?????????????????????????????????????????????????????????????????????????? 描述
/var/www?????????????????????????? Apache WEB站点文件的目录
/var/www/html???????????????? WEB站点的WEB文件
/var/www/cgi-bin???????????? CGI程序文件
/var/www/html/manual?? Apache WEB服务器手册
/var/www/htmll/usage??? webalizer程序文件
?
配置文件
/etc/httpd/conf???? 基于目录的配置文件,.htaccess文件包含对它所在目录中文件的访问控制指令
/etc/httpd/conf/httpd.conf?? Apache WEB服务器配置文件目录
/etc/httpd/conf/srm.conf?????? 主要的Apache WEB服务器配置文件
/etc/httpd/conf/access.conf?? 用来处理文档规范,配置文件类型昨未知的老式配置文件
?
启动脚本
/etc/rc.d/init.d/httpd??????? WEB服务器守护进程的启动脚本
/etc/rc.d/rc3.d/S85httpd?? 将运行级目录(/etc/rc3.d)连接到目录/etc/rc.d/init.d中的启动脚本
?
应用文件
/usr/sbin????? Apache WEB服务器程序文件和应用程序的位置
/usr/doc/?? Apache WEB服务器文档
/var/log/http? Apache 日志文件的位置
?
二、启动和运行Apache服务器
其中一种是:
另处一种是:
httpd除了start\stop命令之外,还有reload,condrestant,status命令,共6种状态
?
三.启动系统时自动运行Apache
若想让系统自动执行Apache,只需执行setup命令,进行Text Mode Setup Utility界面,选中System services中的:httpd服务"即可.
当然,还有一种更方便的图形化方法.选择"应用程序/系统设置/服务器设置/服务/
四.httpd.conf文件详细和配置
旧版中的srm.conf与access.conf文件的内容都被整合到httpd.conf文件中了.
?
#
# Based upon the NCSA server configuration files originally by Rob McCool.
#
# This is the main Apache server configuration file.? It contains the
# configuration directives that give the server its instructions.
# See <URL:[url]http://httpd.apache.org/docs-2.0/[/url] > for detailed information about
# the directives.
#
#
#这是Apache服务器主要配置文件。
#它包含服务器的影响服务器运行的配置指令。
#参见以取得关于这些指令的详细信息
#
# Do NOT simply read the instructions in here without understanding
# what they do.? They're here only as hints or reminders.? If you are unsure
# consult the online docs. You have been warned.?
#
#不要只是简单的阅读这些指令信息而不去理解它。
#这里只是做了简单的说明,如果你没有参考在线文件,你就会被警告。
#
# The configuration directives are grouped into three basic sections:
#? 1. Directives that control the operation of the Apache server process as a
#???? whole (the 'global environment').
#? 2. Directives that define the parameters of the 'main' or 'default' server,
#???? which responds to requests that aren't handled by a virtual host.
#???? These directives also provide default values for the settings
#???? of all virtual hosts.
#? 3. Settings for virtual hosts, which allow Web requests to be sent to
#???? different IP addresses or hostnames and have them handled by the
#???? same Apache server process.
#
#这些配置指令被分为下面三个部分:
#1. 控制整个Apache服务器行为的部分(即全局环境变量)
#2. 定义主要或者默认服务参数的指令,也为所有虚拟主机提供默认的设置参数
#3. 虚拟主机的设置参数
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.? If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
# with ServerRoot set to "/etc/httpd" will be interpreted by the
# server as "/etc/httpd/logs/foo.log".
#
#配置和日志文件名:如果你指定的文件名以“/”开始