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

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

发表评论

电子邮件地址不会被公开。 必填项已用*标注

评论列表(1条)

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

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

联系我们

400-080-6560

在线咨询:点击这里给我发消息

邮件:1660809109@qq.com

工作时间:周一至周五,9:30-18:30,节假日同时也值班