Apache架构与PHP及JavaScript的类结构(2011405)

着手Apache架构分析的目的是了解WEB应用的实现,不过面对上万行(确切的说,以httpd-2.0.64 UNIX为例,代码为约50万行*)的程序源代码,一个人全部看完的概率几乎为0。好在现在有网络,共享着大家的分析结果。

 

Apache的发展让我想到了Linux,最早的L只有1万行代码,现今代码行数提升成百上千倍*,超出大多数人类可全部掌握的程度。

 

以下先引用资料先说明Apache架构的主要内容:

 

1、Apache官网核心应用架构

 

 

core
Core Apache HTTP Server features that are always available
这里面的核心部分似乎是文件系统管理与SOCKET应用,主要管理htdos下的文件、连接网络以及管理C/S。
此部分类似操作系统的功能,不过对设备的操作通过OS API来完成。
这里面的主要头文件包括不限于os.h*等,主要实现各种系统API的封装(包括SOCKET)。
核心的实现程序为core.c,4620行,对应头文件有:
#include "apr.h"
#include "apr_strings.h"
#include "apr_lib.h"
#include "apr_fnmatch.h"
#include "apr_hash.h"
#include "apr_thread_proc.h"    /* for RLIMIT stuff */
#include "apr_hooks.h"
#include "apr_want.h"

#define CORE_PRIVATE
#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_protocol.h" /* For index_of_response().  Grump. */
#include "http_request.h"
#include "http_vhost.h"
#include "http_main.h"     /* For the default_handler below... */
#include "http_log.h"*
#include "rfc1413.h"
#include "util_md5.h"
#include "http_connection.h" //连接模块
#include "apr_buckets.h"
#include "util_filter.h"
#include "util_ebcdic.h"
#include "mpm.h"
#include "mpm_common.h"
#include "scoreboard.h"
#include "mod_core.h"
#include "mod_proxy.h"
#include "ap_listen.h"
实现的功能主要有连接、登录、请求、监听、代理服务器、文件管理、协议、加密等基础应用。
这些应用发展了BeKLLY*的SOCKET,也构成了Apache的核心,这个核心部分不光有HTTP,还可完成其他协议的衍生。

mpm_common
A collection of directives that are implemented by more than one multi-processing module (MPM)
多线程应用*作为服务器一个重要功能单列*
实现程序为mpm_common.c,约1130行,主要的头文件有:
#include "mpm.h"
#include "mpm_common.h"
#include "ap_mpm.h"
#include "ap_listen.h"
#include "mpm_default.h"
这可以理解为一个针对不同操作系统线程使用的补充说明。*

perchild
Multi-Processing Module allowing for daemon processes serving requests to be assigned a variety of different userids
prefork
Implements a non-threaded, pre-forking web server
这是一个类似重写简单Apache的程序,如果要避免多线程的“乱花迷眼”,最好的办法就是先看这个与上面的Core。
threadpool
Yet another experimental variant of the standard  worker MPM
mpm_winnt
This Multi-Processing Module is optimized for Windows NT.
worker
Multi-Processing Module implementing a hybrid multi-threaded multi-process web server

 

未完待续。2011405

 


 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值