码迷,mamicode.com
首页 > Web开发 > 详细

19.2、httpd2.2配置介绍

时间:2018-02-10 21:55:21      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:oba   完成后   first   动态切换   地址   程序   star   list   服务脚本   

1、centos6、centos7安装后相应文件对比



centos6centos7备注
配置文件

/etc/httpd/conf/httpd.conf

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

/etc/httpd/conf/httpd.conf

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


服务脚本

/etc/rc.d/init.d/httpd

/usr/lib/systemd/system/httpd.service
脚本配置文件/etc/sysconfig/httpd

主程序文件

/usr/sbin/httpd

/usr/sbin/httpd.event

/usr/sbin/httpd.worker

/usr/sbin/httpd

httpd2.4支持pmp动态切换
日志文件/var/log/httpd{acces_log,error_log}/var/log/httpd{acces_log,error_log}
模块文件路径
/usr/lib64/httpd/modules/

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


站点文档
/var/www/html
/var/www/html
服务控制

service {stats |stop|restart|status|reload|configtest} httpd

systemctl    httpd {stats |stop|restart|status} 



开机启动
chkconfig httpd onsystemctl enable httpd.service


2、centos6主配置文件组成:/etc/httpd/conf/httpd.conf

    [root@localhost ~]# grep -i   "section"  /etc/httpd/conf/httpd.conf 

    主要有三部分组成:

    Section 1: Global Environment   

    Section 2: 'Main' server configuration

     Section 3: Virtual Hosts

注意:一般而言,section2和section配置是互斥的,默认第二段生效


3、主配置文件格式:

    directive value   //指令   值

    directive:不区分字符大小写

    value:为路径时,是否区分字符大小写,取决于文件系统的属性4、        


4、主文件常用配置:建议作个备份(#cp )

    备份:[root@localhost conf]# cp -iv httpd.conf httpd.conf.bak

    或者 [root@localhost conf]# cp -iv httpd.conf{,.bak}


4.1、修改监听都得IP和端口:

    Listen IP[:80]  //监听绑定的httpd服务主机的ip地址:端口信息 ;可以监听多个地址和端口

      如: Listen 80

        Listen 1.1.1.1:80 

        Listen 2.2.2.2:80


4.2、持久连接:persistent connections

    tcp连接建立后,每个资源获取完成后不会断开,而是继续等待其他资源请求的进行。那么怎么断开比较合理呢?可以通过连接的数量和时间进行限制。

        数量限制:MaxKeepAliveRequests 100  //默认一个会话最大传输100个资源

        时间限制:KeepAliveTimeout 15     //默认最大请求持续时间15s

    

    持久连接的副作用:

        对并发访问量较大的服务器,长连接机制会使得后续某些请求无法得到正常响应。

        折中方法:

            使用较短的持久连接时长,以及较少的请求数量。


    持久连接配置示例:

        KeepAlive Off|On   //关闭或开启长连接

        MaxKeepAliveRequests 100                   

        KeepAliveTimeout 15


    测试方法:

        telnet WEB_SERVER_IP PORT

        GET /URL HTTP/1.1

        HOST: WEB_SERVER_IP

      如:

        [root@localhost ~]# telnet 192.168.0.105 80

        Trying 192.168.0.105...

        Connected to 192.168.0.105.

        Escape character is '^]'.

        GET /test.html http/1.1

        host 192.168.0.105

        注意:敲两次回车,第一次是换行符,第二次是回车符

        

4.3、配置MPM机制:(multipath processing modules:多路处理模块)

    httpd-2.2不支持同时编译多个MPM模块,所以只能编译选定要使用的那个模块;

    centos6的MPM包为此专门提供了三个应用程序文件:httpd(prefork)、httpd.worker、httpd.event,分别用于实现对不同的MPM机制的支持。

    确认现在使用的是哪个程序文件(MPM)的方法:        

        [root@localhost conf.d]# ps aux | grep httpd

        [root@localhost conf.d]# /usr/sbin/httpd -l  


    默认使用的为:/usr/sbin/httpd,其为prefork的MPM模块;

        查看httpd程序的模块列表:

            查看静态编译的模块:[root@localhost conf.d]# httpd -L | less

            产看静态编译及动态编译的模块:[root@localhost conf.d]# httpd -M

      

    更换使用httpd程序,以支持MPM机制:

        修改脚本配置文件:/etc/sysconfig/httpd;更改如下配置:

              HTTPD=/usr/sbin/httpd.worker.{worker,event}                 

            [root@localhost conf.d]# ps aux | grep httpd

            root       4229  0.0  0.0 105444  1000 pts/0    S+   10:50   0:00 less /etc/httpd/conf/httpd.conf

            root       4561  0.0  0.3 173688  3944 ?        Ss   11:50   0:00 /usr/sbin/httpd.worker

        注意:重启服务方可生效,event在centos6处于测试阶段。












    


19.2、httpd2.2配置介绍

标签:oba   完成后   first   动态切换   地址   程序   star   list   服务脚本   

原文地址:http://blog.51cto.com/10631377/2070990

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!