httpd服务——CentOS7

httpd-2.4

新特性:

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

     (2)event MPM生产环境可用

     (3)异步读写机制

     (4)支持每个模块及每目录的单独日志级别定义

     (5)每个请求相关的专业配置

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

     (7)毫秒级持久连接时长定义

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

     (9)新指令,AllowOverrideList

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

     (11)更低的内存消耗

新模块:

     (1)mod_proxy_fcgi

     (2)mod_proxy_scgi

     (3)mod_remoteip

安装httpd-2.4

     依赖于apr-1.4+ ,apr-util-1.4+

         apr:apache portable runtime

    

     CentOS 6:只能编译安装,并且需要先编译安装apr-1.4+ ,apr-util-1.4+ 这两个软件

         默认:apr-1.3.9 ,apr-util-1.3.9

        

         开发环境包组:Development Tools ,Server Platform Development

         开发程序包:pcre-devel

        

         编译安装步骤:

         (1)apr-1.4

             # ./configure –prefix=/usr/local/apr

             # make -j 4 && make install

            

             #arp-util  –with-apr=/usr/local/apr

             make -j 2 && make install

        

        

        

         (2)apr-util-1.4

             # ./configure –prefix =/usr/local/arp-util  –with-apr=/usr/local/apr

             # make -j 4 && make install

        

         (3)httpd-2.4

             ./configure –prefix=/usr/local/apache24 –sysconfig=/etc/httpd24 –enable-so –enable-ssl –enable=cgi –enable-rewrite –with-zlib –with-pcre –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –enable-modules=most<大多数常用的>|all –enable-mpms-shared=all –whith-mpm=prefork

             # make -j 4 && make install

        

         自带的服务控制脚本:apachectl

    

     CentOS 7:

         # yum -y install httpd

        

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

         /etc/httpd/conf.d/*.conf

         /etc/httpd/conf.modules.d/*.conf

    

配置应用:

     (1)切换使用的MPM

         编辑配置文件/etc/httpd/conf.modules.d/00-mpm.conf,启用要启用的MPM相关的LoadModule指令即可

    

     (2)基于IP的访问控制

         允许所有主机访问:Require all granted

         拒绝所有主机访问:Require all deny

        

         控制特定的IP访问:

             Require ip IPADDR:授权指定来源的主机访问

             Require not ip IPADDR:拒绝

        

         控制特定的主机访问:

             Require host HOSTNAME:授权指定来源的主机访问

             Require not host HOSTNAME:拒绝

            

             HOSTNAME:

                 FQDN:特定主机

                 domain.tld:指定域名下的所有主机

        

         <RequireAll>

             Require all granted

             Require not ip 172.16

         </RequireAll>

    

     (3)虚拟主机

         局域FQDN的虚拟主机不再需要NameVirtualHost指令

        

         <VirtualHost *:80>

             ServerName www.gm.com

             DocumentRoot "/www/gm"

             <Directory "/www/gm">

                 Options none

                 AllowOverride none

                 Require all granted

             </Directory>

         </VirtualHost>

    

         注意:任意目录下的页面只有显式授权才能被访问<不写,默认是拒绝>

    

     (4)ssl

         ssl配置要先安装  mod_ssl模块

    

     (5)KeepAliveTimeout #ms

         毫秒级持久连接时长定义

原创文章,作者:megedugao,如若转载,请注明出处:http://www.178linux.com/50779