httpd-2.2和httpd-2.4区别 、请求方法和响应状态码、虚拟主机、访问控制、持久链接

第十周
The Apache HTTP Server is a powerful, efficient, and extensible web server.
2018/2/4 16:33

1、Centos7系统下实现httpd-2.2的安装,并分别实现prefork、worker、event等几种工作方式

MPM

w1

编译过程复习

w2

三种模式转换

w3

附上编译过程脚本

编译脚本

#!/bin/bash
#
# ----------------------------------- pre install scripts -----------------------------------------
wkdir=$PWD
yum -y groupinstall "Development Tools" 
yum -y install zlib-devel
which wget || yum -y install wget
[ -f httpd-2.2.34.tar.gz ] || wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.2.34.tar.gz

# ----------------------------------- complie scripts -----------------------------------------
for i in prefork event worker; do
 [ -d /usr/local/httpd22-$i ] && continue 
 [ -d httpd-2.2.34-$i ] || tar xf httpd-2.2.34.tar.gz 
 mv httpd-2.2.34 httpd-2.2.34-$i
 cd httpd-2.2.34-$i
 ./configure --prefix=/usr/local/httpd22-$i --enable-modules=all --with-mpm=$i
 make -j 8
 make install
 sleep 5
 cd $wkdir
 rm -rf httpd-2.2.34-$i
done

# ----------------------------------- post install scripts -----------------------------------------
[ -L /usr/sbin/httpd.worker ] || ln -sv /usr/local/httpd22-worker/bin/httpd /usr/sbin/httpd.worker
[ -L /usr/sbin/httpd.event ] || ln -sv /usr/local/httpd22-event/bin/httpd /usr/sbin/httpd.event
[ -h /usr/sbin/httpd ] || ln -sv /usr/local/httpd22-prefork/bin/httpd /usr/sbin/httpd
install ${wkdir}/httpd /etc/rc.d/init.d/httpd
cp ${wkdir}/httpd-sys /etc/sysconfig/httpd
chkconfig --list | grep 'httpd' || chkconfig --add httpd

服务脚本

#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: The Apache HTTP Server is an efficient and extensible \
# server implementing the current HTTP standards.

if [ -f /etc/sysconfig/httpd ]; then
 . /etc/sysconfig/httpd
fi
prog=${HTTPD-/usr/sbin/httpd}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
prog=$(basename $prog)

check_prog() {
 [ -f $lockfile ] && RETVAL=0 || RETVAL=1
 return $RETVAL
}
pxr_start() {
 check_prog
 if [ $RETVAL -eq 0 ]; then
 echo "$prog is started."
 else
 #$prog $OPTIONS -DFOREGROUND
 $prog $OPTIONS 
 if [ $? -eq 0 ]; then
 touch $lockfile
 echo "$prog start ok"
 else
 echo "$prog start fail"
 fi
 fi
}
pxr_stop() {
 check_prog
 if [ $RETVAL -eq 0 ]; then
 kill -9 `pgrep $prog` &> /dev/null
 rm -f $lockfile
 [ $? -eq 0 ] && echo "$prog stop finished." || echo "$prog stop fail."
 else
 echo "$prog is stopped."
 fi
}
pxr_restart() {
  pxr_stop
  pxr_start
}
pxr_status() {
 check_prog
 [ $? -eq 0 ] && echo "$prog is running." || echo "$prog is stopping"
}

case "$1" in
 start|stop|restart|status)
 pxr_$1
 ;;
 *)
 echo $"Usage: $prog {start|stop|restart|status}"
 RETVAL=2
 ;;
esac
exit $RETVAL

# 注意:脚本有缺陷,要更换MPM时, 需要先停止服务....

2、简述request报文请求方法和状态响应码

request报文请求方法

w5

状态响应码

w4

3、详细描述httpd虚拟主机、站点访问控制、基于用户的访问控制、持久链接等应用配置实例

实现环境

x1

一、httpd虚拟主机

x2

(1) 基于IP的虚拟主机(httpd-2.4)

x3

(2) 基于PORT的虚拟主机(httpd-2.4)

x4

(3) 基于Host:(httpd-2.2/httpd-2.4)

x5

x6

 

二、站点访问控制

x7

x8

x9

三、基于用户的访问控制

x10

x11

四、持久链接

x12

x13

x14

注:完成作业路径:四 -> 二 -> 一 -> 三;参考:http://www.178linux.com/89108

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/91448

(0)
逆神阳逆神阳
上一篇 2018-02-01 20:24
下一篇 2018-02-05 08:43

相关推荐

  • 一起学DNS系列(十五)DNS查询工具之NSLOOKUP的使用

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://jeffyyko.blog.51cto.com/28563/259092    上一节里我们讨论了有关DIG工具的用法,本节将对windows下nslookup工具的一些主要命令进行描述。  …

    2015-03-17
  • N21沉舟第九周作业

    1、写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; 方法一: #!/bin/bash         #     dec…

    Linux干货 2016-08-30
  • lvs-dr模型

    dr 模型 1、 directory ,node1 ,node2 三台主机都是一块网块, 并且网卡都为桥接,且node1,nod2,不需要指定网关 在director主机中执行   #ip addr add 192.168.1.20/32 dev ens33 # ipvsadm -A -t 192.168.1.20:80 -s rr # ipvsa…

    Linux干货 2017-08-26
  • N25-第十周

    1、请详细描述CentOS系统的启动流程(详细到每个过程系统做了哪些事情) 一、内核空间详细过程如下: POST –> BootSequence(BIOS) –> Bootloader(MBR) –> kernel(ramdisk) –> rootfs(只读) –> /sbin/init(systemd) 1.POST:(pow…

    Linux干货 2017-05-30
  • MySQL基础知识

    1、SQL:结构化查询语言(Structured Query Language): DDL:Data Definition Language(数据定义语言): 其语句包括动词CREATE和DROP。在数据库中创建新表或删除表(CREAT TABLE 或 DROP TABLE);为表加入索引等。DDL包括许多与人数据库目录中获得数据有关的保留字。它也是动作查询…

    2017-11-20
  • Linux三剑客之grep

    grep(Globel Search Regular Expression and Printing out the line)全面搜索正则表达式并把行打印出来)是一个强大的文本搜索工具,使用正则表达式搜索文本的文本,并把结果打印出来。Unix家族包括grep、egrep和fgrep。egrep是扩张的正则表达式它支持更多的字符,fgrep是fast gre…

    Linux干货 2016-08-12

评论列表(1条)

  • 马哥教育
    马哥教育 2018-02-05 22:27

    赞,总结的比较全面,也有自己的理解,加油~