初识apache服务(2)---httpd的相关文件

配置文件:

  • /etc/httpd/conf/httpd.conf 主配置文件
  • /etc/httpd/conf.d/*.conf 子配置文件
  • /etc/httpd/conf.d/conf.modules.d/ 模块加载的配置文件

检查配置语法httpd –t

模块文件路径:

  • /etc/httpd/modules
  • /usr/lib64/httpd/modules

默认站点网页文档根目录:

  • /var/www/html

日志文件目录:

  • /var/log/httpd/access_log访问日志
  • /var/log/httpd/error_log错误日志

默认配置文件

[root@centos8 ~]#grep -Ev '^ *#|^$' /etc/httpd/conf/httpd.conf
ServerRoot "/etc/httpd"  ##设置根目录,后面的/实际都是在/etc/httpd/下面
Listen 80  ##监听端口,可重复出现,默认监听本机所有IP,可指定监听本机特定IP,例:192.168.1.100:8080
Include conf.modules.d/*.conf  ##包含加载模块配置目录
User apache  ##运行httpd的用户
Group apache  ##运行httpd的组
ServerAdmin root@localhost
<Directory />
    AllowOverride none
    Require all denied
</Directory>
DocumentRoot "/var/www/html"  ##指向的路径为URL路径的起始位置
<Directory "/var/www">  ##/path 必须显式授权后才可以访问
    AllowOverride None
    Require all granted  ##所有访问授权
</Directory>
<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
<IfModule dir_module>
    DirectoryIndex index.html  ##定义站点主页面,可加如:index.htm index.php(需安装PHP模块)
    						   ##如访问www.yunmix.top和www.yunmix.top/index.html是一样
</IfModule>
<Files ".ht*">
    Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>  ##日志内容格式模块
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
    CustomLog "logs/access_log" combined  ##使用上述日志格式
</IfModule>
<IfModule alias_module> ##定义路径别名
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>
<IfModule mime_module>
    TypesConfig /etc/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8  ##设定默认字符集
<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf  ##包含子配置文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值