apache配置文件详解

配置文件详解
文件位置:
/etc/httpd/conf/httpd.conf

# vim /etc/httpd/conf/httpd.conf 
ServerRoot "/etc/httpd"      //服务器的根路径,改文件中所有涉及到的路径的根都是相对它而言的。
Listen 80        //监听的端口
Include conf.modules.d/*.conf   //包含辅助配置文件目录下的所有以.conf结尾的;;;文件(/etc/httpd/conf.modules.d/*.conf)

User apache       //运行web服务的用户
Group apache    

ServerAdmin root@localhost    //管理员邮件地址
#ServerName www.example.com:80  //服务器的名字
ServerName www.uplooking.com:80

<Directory />   ---容器,对整个目录中的东西进行设置,权限等等
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/var/www/html"    //web服务文档根路径

<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks     //Indexes:索引目录,(默认没有主页时),允许索引目录   FollowSymLinks:支持符号链接  软连接
    AllowOverride None     //和访问权限有关  可以进行认证        None --不使用认证  all--应用所有的认证指令  AuthConfig  --允许使用与认证授权相关的指令
    Require all granted    //访问控制  所有人方行
</Directory>
    
<IfModule dir_module>
    DirectoryIndex index.html    //网站索引页的名称
</IfModule>

<Files ".ht*">   //以所有.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>   
    # Alias /webpath /full/filesystem/path   //给路径设置别名  意味着访问http://Server_ip/webpath时,其页面文件来自于/full/filesystem/path中
    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   //默认字符集


#EnableMMAP off    //线程模式
EnableSendfile on   //开启进程模式(默认)

IncludeOptional conf.d/*.conf    //包含辅助配置文件目录下的所有以.conf结尾的文件(/etc/httpd/conf.d/*.conf)

猜你喜欢

转载自blog.csdn.net/qq_43377292/article/details/86492089