2. module?
• 코어와 분리 독립된 코드
• 모듈 요약
• ex)
MPM : 다중처리 모듈
Base : HTTP 서버와 같이 컴파일 되고 설치됨
Extension : 서버와 같이 컴파일 되지 않지만, 추가 설
치 가능
Experimental : 배포본에 포함되어있지 않은 실험적
인 모듈
External : 기본적으로 아파치 배포본에 포함되지 않음.
3. 모듈 종류?
• 핵심 모듈 : MPM 모듈, 코어 모듈등
• 기본 모듈 : 설치시 포함되는 모듈들
• 확장 모듈 : 핵심/기본이 아닌 모듈들
$ ./apachectl -l
Compiled in modules:
core.c
mod_so.c
http_core.c
worker.c
5. typedef struct module_struct module;
struct module_struct {
int version;
int minor_version;
int module_index;
const char *name;
void *dynamic_load_handle;
struct module_struct *next;
unsigned long magic;
void (*rewrite_args) (process_rec *process);
void *(*create_dir_config) (apr_pool_t *p, char *dir);
void *(*merge_dir_config) (apr_pool_t *p, void *base_conf,
void *new_conf);
void *(*create_server_config) (apr_pool_t *p, server_rec *s);
void *(*merge_server_config) (apr_pool_t *p, void *base_conf,
void *new_conf);
const command_rec *cmds;
void (*register_hooks) (apr_pool_t *p);
};
*next : 모듈들은 단순 연결 리스트로
연결되어있음.
create_dir_config ~
merge_server_config : config 파
일에 설정 방법과 관련됨.
cmds : 지시자와 이를 처리할 함수
register_hooks : 다른 콜백 함수를 정
의하여 사용할 수 있다.
6. module AP_MODULE_DECLARE_DATA example_module =
{
STANDARD20_MODULE_STUFF,
x_create_dir_config, /* per-directory config creator */
x_merge_dir_config, /* dir config merger */
x_create_server_config, /* server config creator */
x_merge_server_config, /* server config merger */
x_cmds, /* command table */
x_register_hooks, /* set up other request processing hooks */
};
모듈명 : exmple_module
조금 더 설명을..
7. command table : directive를 정의한다.
ex) ProxyPass 디렉티브는 아래와 같이 정의되어있다.
sample)
ProxyPass "/foo" "http://foo.example.com/bar"
8. static const command_rec x_cmds[] =
{
AP_INIT_NO_ARGS(
"Example", /* directive name */
cmd_example, /* config action routine */
NULL, /* argument to include in call */
OR_OPTIONS, /* where available */
"Example directive - no arguments" /* directive description */
),
{NULL}
};
demo에서 살펴 볼 example module의 command는 아
래와 같이 정의되어있다.
$ cat http.conf
…
….
Example
…
9. $ wget http://http.apache.org/download/httpd-2.4.17.tar.bz2
$ tar xvfj httpd-2.4.17.tar.gz2
$ cd httpd-2.4.17
$ ./configure —prefix=/opt/httpd2.4 —enable-example-hooks
$ cd /opt/httpd2.4
$ sudo ./apachectl -k start
$ sudo ./apachectl -k stop
예제 모듈 빌드 & 설치