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

相关推荐

  • 网络通信安全基础OpenSSL

    OpenSSL: NIST: 保密性: 数据保密性 隐私性 完整性: 数据完整性 系统完整性 可用性  安全攻击: 被动攻击:窃听 主动攻击:伪装、重放、消息篡改、拒绝服  安全机制: 加密、数字签名、访问控制、数据完整性、认证交换、流量填充、路由控制、公证 安全服务: 认证 访问控制 数据保密性 连接保密性 无连接保密性 选择域保密性 …

    Linux干货 2015-09-06
  • 程序包的编译安装

    程序包的编译安装 之所以需要安装编译程序包,是为了能及时更新程序包,制作好的rpm包,版本一般都有点老了,所以编译安装是必报的,而且我们可以自己定义安装路径,想卸载直接删除就KO了; 在centos7.3环境下安装apache http服务: 1.首先获取最新的apache源码包下载到/root目录下; 2.检查安装环境,没有就安装环境:   记住…

    Linux干货 2017-03-09
  • 网络班N27 第四周作业

    1、 复制/etc/skel目录为/home/tuserl,要求/home/tuserl及其内部文件的属组和其他用户均没有任何访问权限。 [root@ ~]# cp -r /etc/skel /home/tuserl [root@ ~]# chmod -Rv 700 /home/tuserl/ mode of ‘/home/tuserl/’ changed …

    Linux干货 2017-08-19
  • Bash学习基础知识一“命令”

    Bash 学习基础知识 目录 一、Shell是个啥? 二、BASH的命令     2.1 命令的语法格式     2.2 什么是命令     2.4 命令的类型     …

    Linux干货 2015-04-03
  • 8.3号,第6天

    三种权限rwx对文件和目录的不同意义: 权限对于目录的意义: 1,r权限:拥有此权限表示可以读取目录结构列表,也就是说可以查看目录下的文件名和子目录名,注意:仅仅指的是名字。 2、w权限:拥有此权限表示具有更改该目录结构列表的权限,总之,目录的w权限与该目录下的文件名或子目录名的变动有关,注意:指的是名字。具体如下:      …

    Linux干货 2016-08-05
  • 基于heartbeat v1+ldirectord实现LVS集群高可用

    前言 高可用集群,High Availability Cluster,简称HA Cluster,是指以减少服务中断时间为目的的服务器集群技术。通过上文可以看出,LVS集群本身并不能实现高可用,比如Director Server不能检测Real Server的健康度,一旦其中一台或全部Real Server宕机,Director Server还会继续转发请求,…

    Linux干货 2015-06-08

评论列表(1条)

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

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