httpd-2.4新特性:

        (1) MPM支持运行DSO机制;以模块形式按需加载

        (2) 支持event MPM

        (3) 支持异步读写

        (4) 支持每模块及每个目录分别使用各自的日志级别

        (5) 每请求配置;<If>

        (6) 增强版的表达式分析器

        (7) 支持毫秒级的keepalive timeout

        (8) 基于FQDN的虚拟主机不再需要NameVirtualHost指令

        (9) 支持用户自定义变量

新模块:mod_proxy_fcgi,mod_ratelimit,mod_remoteip

修改了一些配置机制:不再支持使用Order, Deny, Allow来做基于IP的访问控制,都是用require来设定。


Apache2.4

        主配置文件:/etc/httpd/conf/httpd.conf

        模块相关的配置文件目录:/etc/httpd/conf.modules.d/*.conf

        模块配置文件:/etc/httpd/conf.d/*.conf


Centos7上的启动命令:

        将httpd加入到系统服务:chkconfig httpd on

        启动服务:systemctl restart httpd.service     {start|stop|restart|status|reload}

        要是不加到系统服务只能用:/sbin/httpd -k start 命令来启动或重启服务。


禁止请求特定后缀后的路径:

        这项设置禁止在设置的特定后缀名后加上路径再来请求,如原来的请求地址为 index.html,但是用户在后面添加了路径变为 index.html/more/ 这样的路径来请求,这个设置用来拒绝这样的请求,返回404信息。

    <Files ".ht*">

        Require all denied

    </Files>


目录需要授权

        在2.4版本中没有明确授权的目录是没有权限访问内容的,所以需要明确指定访问的目录。

DocumentRoot "/www/htdocs"            如果这个目录没有被授权访问则任何人都不可访问。

<Directory "/www/htdocs">

        Options Indexes FollowSymLinks

        AllowOverride None

        Require all granted                这里授权这个目录允许任何人访问。

</Directory>


拒绝访问设置

        当要拒绝单独IP或主机访问时要在<RequireAll>标签中定义,不在支持Order、Deny、Allow的方式,新格式如下:

<Directory "/www/htdocs">

        ......

        <RequireAll>

                Require all granted

                Require not ip 192.168.96.128

                Require not ip 192.168.0.0/16

                Require not host phishers.example.com moreidiots.example

                Require not host gov

        </RequireAll>

</Directory>


        Require all granted       无条件允许访问。

        Require all denied        访问被无条件拒绝。

        Require env env-var [env-var] ...        只有在给定的环境变量之一被设置的情况下才允许访问。

        Require method http-method [http-method] ...    只有给定的HTTP方法才允许访问。

        Require expr expression                     如果表达式计算结果为true,则允许访问。

        Require user userid [userid] ...            只有指定的用户才能访问资源。

        Require group group-name [group-name] ...    只有指定组中的用户才能访问资源。

        Require valid-user                             所有有效的用户都可以访问资源。

        Require ip 10 172.20 192.168.2         指定IP地址范围内的客户端可以访问资源。


        详细内容:http://httpd.apache.org/docs/2.4/mod/mod_authz_core.html#require


ssl配置

        ssl与2.2相同,启用模块LoadModule ssl_module modules/mod_ssl.so 配置相同。