您的位置:首页 > 运维架构 > Apache

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

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

 

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

 

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

 

1、Apache官网核心应用架构

 

 

coreCore 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_commonA 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"这可以理解为一个针对不同操作系统线程使用的补充说明。*
perchildMulti-Processing Module allowing for daemon processes serving requests to be assigned a variety of different useridspreforkImplements a non-threaded, pre-forking web server这是一个类似重写简单Apache的程序,如果要避免多线程的“乱花迷眼”,最好的办法就是先看这个与上面的Core。threadpoolYet another experimental variant of the standard 
worker
 MPMmpm_winntThis Multi-Processing Module is optimized for Windows NT.workerMulti-Processing Module implementing a hybrid multi-threaded multi-process web server
 

未完待续。2011405

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息