apcha2配置文件翻译

apache2.conf

这是apache2的主要的配置文件,它包含了给服务器的配置指令,详细的指定海鸥解释和Debian的指令提示可以看http://httpd.apache.org/docs/2.4/

关于apache2的指令是如何在Debian上工作的,在Debian上的Apache2的网络服务器的配置配置文件是和上游的建议的方式是不同的,因为Debian的默认的Apache2的安装是通过添加和移除模块来实现的,虚拟主机和额外的配置指令尽可能的要灵活,目的是尽可能让配置的改变和管理更加方便

apache2中的配置文件是分散的,下面是配置文件的书目录,所有的都在系统的 /etc/apache2/ 目录中

#	/etc/apache2/
#	|-- apache2.conf
#	|	`--  ports.conf
#	|-- mods-enabled
#	|	|-- *.load
#	|	`-- *.conf
#	|-- conf-enabled
#	|	`-- *.conf
# 	`-- sites-enabled
#	 	`-- *.conf
  • apache2.conf是主要的配置文件,它将所有的配置文件通过#include的方包含在这个文件中,在启动Web服务的时候来按照这个配置文件进行配置
  • ports.conf通常在配置文件中所包含,它定义了监听端口,监听端口是一个连接的入口,这些定义的监听端口都可以被第三方在任何时候连接
  • mods-enabled/, conf-enabled/, sites-enabled中的配置文件分别包含了各自指定了各自所管理的模块,他们使用symlinking可用的配置文件来激活各个模块,他们可以使用我们的帮助文件 a2enmod/a2dismod, a2ensite/a2dissite, a2enconf/a2disconf来管理,详细的内容看他们所关联的页面
  • 二进制文件名为apache2,通过在默认的文件中使用环境变量,apache2需要使用/etc/init.d/apache2或apache2ctl来启动/结束apache2直接调用 /usr/bin/apache2将不会使用默认的配置来运行apache2

全局配置

ServerRoot: 目录树的顶:包含服务的配置文件,故障和记录文件
注意!如果你想将其配置在一个NFS(或者其他网络中),需要阅读互斥锁(Mutex)文档(在http://httpd.apache.org/docs/2.4/mod/core.html#mutex>),这将省去你很多麻烦。

不要在目录尾部添加斜杠

接受的序列化锁文件必须储存在本地硬盘里

# 这个路径下将会存放shm和其他的运行文件
DefaultRuntimeDir ${APACHE_RUN_DIR}
# PidFile: 这个文件是服务器在开始启动的时候记录它的进程id的文件,它应该设置在 /etc/apache2/envvars 中
PidFile ${APACHE_PID_FILE}
# Timeout: 接受和发送超时的事件设置
Timeout 300
# KeepAlive: 是否允许持久连接(在一次连接中有超过1次的请求)设置“off”来禁用
KeepAlive On
# MaxKeepAliveRequests: 在持久连接中允许的最大数量的请求,设置为0意味着是一个非限制的连接,我们建议设置这个数值高一点,这样性能会好一点
MaxKeepAliveRequests 100
# KeepAliveTimeout: 从一个客户端中等待下一次请求的等待时间
KeepAliveTimeout 5
# 这些需要设置在 /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
# HostnameLookups: 记录客户端的连接名和他的Ip地址,比如:
www.apache.org (on) or 204.62.129.132 (off)
默认是关闭的,因为需要在人们之情的情况下来打开这个功能,打开意味着每一个客户端连接的时候都会看一下他们的主机名
HostnameLookups Off
# 故障记录文件的位置,如果你没有使用<VirtualHost>来指定一个故障记录,相关关于这个虚拟主机的故障信息将会记录在这里,如果你指定一个<VirtualHost>连接的记录文件,这个主机的故障信息将会记录在这里
ErrorLog ${APACHE_LOG_DIR}/error.log
# 故障记录的等级
现在支持的级别:trace8, ..., trace1, debug, info, notice, warn, error, crit, alert, emerg.
方法:ogLevel info ssl:warn
LogLevel warn
# 包含的模块配置文件
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
# 包含的端口监听文件
Include ports.conf
# 设置HTTPD服务的默认的秘密等级,这不允许访问除了 /usr/share 和 /var/www 之外的目录,前者用于在Debian中打包的应用程序,后者是用来访问web服务器的静态文件,如果你的系统在 /srv 中提供了子目录的服务进程,你应该允许在这里访问,或者在一个相关的虚拟主机中
<Directory />
	Options FollowSymLinks
	AllowOverride None
	Require all denied
</Directory>

<Directory /usr/share>
	AllowOverride None
	Require all granted
</Directory>

<Directory /var/www/>
	Options Indexes FollowSymLinks
	AllowOverride None
	Require all granted
</Directory>

#<Directory /srv/>
#	Options Indexes FollowSymLinks
#	AllowOverride None
#	Require all granted
#</Directory>
# AccessFileName: 对于附加的配置指令,在每一个目录中查找的文件
AccessFileName .htaccess
# 下面几行来阻止客户端查看.htaccess 和 .htpasswd文件
<FilesMatch "^\.ht">
	Require all denied
</FilesMatch>
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值