阅读背景:

Apache主要配置文件http.conf

来源:互联网 

1、基本概念

Define SRVROOT "/Apache24"
ServerRoot "${SRVROOT}"
#Apache安装的根路径

#Listen 12.34.56.78:80
Listen 80
#Apache服务器监听的IP地址和端口,只写端口表示会监听这台服务器上所有的IP

# LoadModule foo_module modules/mod_foo.so
#动态加载模块,比如代理模块、PHP模块(这样才能识别PHP)
#LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
......

User daemon
Group daemon
#设置Apache在什么账户下运行,如果使用root登录则存在很大风险,用户组Group起到风险隔离

ServerAdmin [email protected]
#有些时候服务器出现故障时,需要服务器自动发邮件给管理员

ServerName localhost:80
#ServerName可以是机器名或IP,即localhost或127.0.0.1

<Directory />
    AllowOverride none
    Require all denied
</Directory>
#设置接入的访问权限

DocumentRoot "${SRVROOT}/htdocs"
#Apache服务器下面的网站默认路径是在htdoc,即只需要把PHP文件放在该文件夹下就能被Apache找到、识别并执行
<Directory "${SRVROOT}/htdocs">
......
#具体路径以及权限设置和属性

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
#如果不设置具体访问哪个文件,就会返回DirectoryIndex指定的网页,按顺序查找,比如index.html、index.php等

<Files ".ht*">
    Require all denied
</Files>
#某一类或某一个文件的权限设置

ErrorLog "logs/error.log"
#服务器出错的时候日志输出位置,这里不以/开头表示相对路径,即相对于ServerRoot而言的路径

LogLevel warn
#日志输出级别的设置,开发的时候可以设置debug,这样调试信息丰富,但是文件产生的较多,实际应用时设置warm即可

<IfModule logio_module>
   # You need to enable mod_logio.c to use %I and %O
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
#日志文件输出格式

CustomLog "logs/access.log" common
#自定义写log的路径

<Directory "${SRVROOT}/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>
#规定cgi-bin路径下的权限设置

Include conf/extra/httpd-autoindex.conf
#其他路径下的配置文件

<IfModule ssl_module>
#Include conf/extra/httpd-ssl.conf
Include conf/extra/httpd-ahssl.conf
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
#SSL模块的配置属性Define SRVROOT "/Apache24"
Se



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: