Apache配置文件详解

2019-01-27 16:22

Apache配置文件详解

Apache配置文件的分布(Apache v2.2.X)

|- /etc/httpd/conf/httpd.conf?(Apache的主配文件)

httpd.conf是Apache的主配文件,整个Apache也不过就是这个配置文件,里面几乎包含了所有的配置。有的distribution都将这个文件拆分成数个小文件分别管理不同的参数。但是主要配置文件还是以这个文件为主。只要找到这个文件名就知道如何设置了。后面会详细解释Apache主配文件的每一行配置 |- /etc/httpd/conf.d/*.conf ? (include文件)

如果你不想要修改原始配置文件httpd.conf的话,那么可以将你自己的额外参数文件独立出来,注意以.conf结

尾放在/etc/httpd/conf.d/目录下。重启Apache的时候,这个配置文件就会被读入主配文件之中了。他的好处就是当你在进行系统升级的时候,几乎不需要改动原本的配置文件,只要将你自己的额外参数文件复制到正确的地点即可,维护起来非常方便。 |- /usr/lib64/httpd/modules/ |- /etc/httpd/modules/

Apache支持很多的外挂模块,例如PHP以及SSL都是Apache外挂的一种。所有你想要使用的模块文件默认是

放置在这个目录当中的。

|- /var/www/html/ ? (网页根目录)

这个目录就是Apache默认的存放首页的目录(默认是index.html)

|- /var/www/error/

当因为服务器设置错误,或是浏览器要求的数据错误时,在浏览器上出现的错误信息就以这个目录的默认信息

为主

|- /var/www/icons/

这个目录提供Apache默认给予的一些小图示,可以随意使用。

|- /var/www/cgi-bin/

默认给一些可执行的CGI(网页程序)程序放置的目录。

|- /var/log/httpd/

默认的Apache日志文件都放在这里,对于流量比较大的网站来说,这个目录要格外注意,这里的数据文件可

能会非常大。 |- /usr/sbin/apachectl

这个就是Apache的主要执行文件,这个执行文件其实就是一个Shell Script而已,他可以主动地侦测系统上面

的一些设置值,好让你启动Apache时更简单一些。 |- /usr/sbin/httpd

这个是主要的Apache二进制执行文件。

|- /usr/bin/htpasswd ? (Apache密码保护)

在当你想要登入某些网页时你需要输入帐号与密码,那Apache本身就提供一个最基本的密码保护方式,该密

码的产生就是通过这个命令来实现的。

Apache主配文件总览

Apache的主配文件httpd.conf主要包含四大部分 |- 全局配置部分 |- 中心主机配置部分 |- 虚拟主机配置部分 |- conf.d外置扩展配置部分

Apache-httpd.conf配置文件详解

#

# This is the main Apache server configuration file. It contains the # configuration directives that give the server its instructions.

# See for detailed information. # In particular, see

# # for a discussion of each configuration directive. #

#这是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. #

# Configuration and logfile names: If the filenames you specify for many # of the server's control files begin with \# server will use that explicit path. If the filenames do *not* begin # with \# with ServerRoot set to \# server as \#

### Section 1: Global Environment #

# The directives in this section affect the overall operation of Apache, # such as the number of concurrent requests it can handle or where it # can find its configuration files. # #

# Don't give away too much information about all the subcomponents # we are running. Comment out this line if you don't mind remote sites

# finding out what major optional modules you are running ServerTokens OS

#这个项目仅仅是在告知客户端我们服务器的版本和操作系统而已,不需要改动他 #如果不在乎你的系统信息被远程用户查询到,则可以将这个项目注释掉(不建议) #

# ServerRoot: The top of the directory tree under which the server's # configuration, error, and log files are kept. #

# NOTE! If you intend to place this on an NFS (or otherwise network) # mounted filesystem then please read the LockFile documentation

# (available at ); # you will save yourself a lot of trouble. #

# Do NOT add a slash at the end of the directory path. #

ServerRoot \

#服务器设置的最顶层目录,有点类似于chroot那种感觉。包括logs , modules等 #的数据都应该要放置在此目录下面(如果这些配置没有声明成绝对路径的话) #

# PidFile: The file in which the server should record its process # identification number when it starts. Note the PIDFILE variable in # /etc/sysconfig/httpd must be set appropriately if this location is # changed. #

PidFile run/httpd.pid

#放置PID的文件,可方便apache软件的管理。只有相对路径考虑ServerRoot设置值, #所以文件在/etc/httpd/run/httpd.pid #

# Timeout: The number of seconds before receives and sends time out. #

Timeout 60

#不论接收或发送,当持续连接等待超过60秒则该次连接就中断 #一般来说,此数值在300秒左右即可,不需要修改这个原始值 #

# KeepAlive: Whether or not to allow persistent connections (more than # one request per connection). Set to \#

KeepAlive Off

#这里最好把默认值“Off”修改为“On”

#这里表示是否允许持续性的连接,也就是一个TCP连接可以具有多个文件资料传送的要求 #举例来说,如果你的网页内含有很多图片文件,那么这一次连接就会将所有的数据传送完 #而不必每一个图片都需要进行一次TCP连接。 #

# MaxKeepAliveRequests: The maximum number of requests to allow # during a persistent connection. Set to 0 to allow an unlimited amount. # We recommend you leave this number high, for maximum performance. #

MaxKeepAliveRequests 100

#可以将默认的100改成500或更高

#与上一个设置的值KeepAlive有关,当KeepAlive的值设置为On的时候,这个数值可以决定 #该次连接能够传输的最大传输数量。为了提高效率则可以改大一点。0代表不限制 #

# KeepAliveTimeout: Number of seconds to wait for the next request from the # same client on the same connection. #


Apache配置文件详解.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:机械专业到福田得暑期社会实践报告范文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: