httpd.conf파일은 아파치의 환경설정 파일입니다.
여기에 우리가 만든 설정지시자(Configuration Directive)를 넣어 아파치를 컨트롤 해보겠습니다.
Configuration Directive를 쉽게 "지시자"라 앞으로 부르겠습니다.
아파치 동작에 영향을 주는 지시자는 성격상 크게 두가지로 분류되어집니다.
하나는 서버단위로 설정하는 것(servier-specific)이고, 다른 하나는 디렉토리단위로 설정하는 것(directory-specific)입니다. 아주 많은 버츄얼호스트 정보와 각 호스트에 적용되어야 할 디렉토리. 각각에 맞는 설정정보를 아파치는 적절한 때에 생성하고 읽어와야하기 때문에 나름대로 이렇게 분류하여 설정정보를 갖게 됩니다.
1. create_dir_config()는 함수 이름 그대로 해석하면
"디렉토리 단위로 설정할 수 있도록 무언가를 만들어라."
실제로 하는 일도 비슷합니다.
<Directory>, <Location>등이 갖는 설정정보로 per-directroy configuration 정보를 만들고 그 정보를 아파치서버에게 알려줍니다.
2. create_server_config()
per-server configuration 정보를 만들고 그 정보를 아파치서버에게 알려줍니다.
3. merge_server_config()
각각의 모듈이 갖는 설정은 전체설정의 영향을 받습니다.
이미 전체설정한 내용에 대해 모듈이 새로 설정을 한다면 전체설정은 의미가 없어집니다. 설정내용을 합치고 결국 모듈에서 재정의한 내용만을 아파치 실행시 사용합니다.
즉, 설정정보를 병합(merge)하여 처리한다고 할 수 있겠습니다.
merge_server_config()는블럭안에 있는 설정정보와 parant server 설정정보 병합(merge)할 때 사용됩니다.
4. merge_dir_config()
merge_dir_config()는 merge_server_config()와 달리 request time에 두개의 per-directory 설정정보가 하나의 디렉토리에 적용될 때, 사용됩니다. 두개의 설정정보가 하나로 합쳐서 새로운 설정정보로 만들어지고, 새로운 설정에 따라 결과가 처리되는 것입니다.
이상, 환경설정에 관련된 아파치 API 함수 4개 알아봤습니다.
그 다음은 command_rec관해 알아봅시다.
원형을 보게되면,
typedef struct command_struct
{
const char *name;
/* 명령어의 이름 */
const char *(*func) ();
/* 호출될 함수 */
void *cmd_data;
/* 복수의 명령어를 갖는 함수를 위한 데이터 */
int req_override;
/* What overrides need to be allowed to enable this command.*/
enum cmd_how args_how;
/* 구체적 설정을 위한 값들 */
const char *errmsg;
/* syntax 에러시, 메세지 */
} command_rec;
mod_alias 의 경우를 보겠습니다. mod_alias는 다음과 같이 command_rec구조체에 정보를 입력합니다.
static const command_rec action_cmds[] =
{
{"Action", add_action, NULL, OR_FILEINFO, TAKE2,
"a media type followed by a script name"},
{"Script", set_script, NULL, ACCESS_CONF | RSRC_CONF, TAKE2,
"a method followed by a script name"},
{NULL}
};
Action, Script는 실제로 httpd.conf를 열어보면 볼 수 있을 겁니다.
그리고 이 단어들은 httpd.conf의 어느 위치에 와도 상관이 없습니다.
이런 정보는 어디에 있느냐?
세번째 인자값에 OR_FILEINFO라구 적혀있죠? 그것이 command명령어의 범위를 나타내 줍니다.
구체적인 건 밑에 적어놨습니다.
{"Action", add_action, .., OR_FILEINFO, TAKE2,..}
Action 이란 단어가 httpd.conf에 보이면 이것을 처리할 함수를 찾아야 하죠.그 함수는 여기서 add_action이 됩니다.
그리고 add_action 함수는 2개의 인자값을 취하게 되네요..
인자값 개수는 어떻게 알았냐면 TAKE2라고 적혀있는 부분이 그것을 알려줍니다. 인자값이 한개이면 TAKE1이라고 적어주세요~
그리고 만약 세개가 필요하다면 TAKE3라고 적어주시면 됩니다.
좀전에 OR_FILEINFO와 같이 범위설정하는 거 있었죠?
command_rec 구조체에 정수형으로 정의된 req_overide인데,
이 값은 다음과 같은 값을 갖습니다.
4개의 API함수, command_rec구조체 등에 대해 간단히 알아봤습니다. 다음 장에서 간단한 예제파일을 보면서 설명하겠습니다.
여기에 우리가 만든 설정지시자(Configuration Directive)를 넣어 아파치를 컨트롤 해보겠습니다.
Configuration Directive를 쉽게 "지시자"라 앞으로 부르겠습니다.
이 지시자라는거 머냐면 httpd.conf파일 열어보시면,
[CODE]<Directory> Options FollowSymLinks AllowOverride None </Directory>[/CODE]
여기서 Directory 이런걸 말합니다.
[CODE]<Directory> Options FollowSymLinks AllowOverride None </Directory>[/CODE]
여기서 Directory 이런걸 말합니다.
아파치 동작에 영향을 주는 지시자는 성격상 크게 두가지로 분류되어집니다.
하나는 서버단위로 설정하는 것(servier-specific)이고, 다른 하나는 디렉토리단위로 설정하는 것(directory-specific)입니다. 아주 많은 버츄얼호스트 정보와 각 호스트에 적용되어야 할 디렉토리. 각각에 맞는 설정정보를 아파치는 적절한 때에 생성하고 읽어와야하기 때문에 나름대로 이렇게 분류하여 설정정보를 갖게 됩니다.
우리가 설정정보를 컨트롤하기위해 알아야하는 네 개의 함수입니다.
void *create_dir_config(pool *p, char *dir)
void *create_server_config(pool *p, server_rec *s)
void *merge_server_config(pool *p, void *base_conf, void *new_conf)
void *merge_dir_config(pool *p, void *base_conf, void *new_conf)
void *create_dir_config(pool *p, char *dir)
void *create_server_config(pool *p, server_rec *s)
void *merge_server_config(pool *p, void *base_conf, void *new_conf)
void *merge_dir_config(pool *p, void *base_conf, void *new_conf)
1. create_dir_config()는 함수 이름 그대로 해석하면
"디렉토리 단위로 설정할 수 있도록 무언가를 만들어라."
실제로 하는 일도 비슷합니다.
<Directory>, <Location>등이 갖는 설정정보로 per-directroy configuration 정보를 만들고 그 정보를 아파치서버에게 알려줍니다.
2. create_server_config()
per-server configuration 정보를 만들고 그 정보를 아파치서버에게 알려줍니다.
3. merge_server_config()
각각의 모듈이 갖는 설정은 전체설정의 영향을 받습니다.
이미 전체설정한 내용에 대해 모듈이 새로 설정을 한다면 전체설정은 의미가 없어집니다. 설정내용을 합치고 결국 모듈에서 재정의한 내용만을 아파치 실행시 사용합니다.
즉, 설정정보를 병합(merge)하여 처리한다고 할 수 있겠습니다.
merge_server_config()는
4. merge_dir_config()
merge_dir_config()는 merge_server_config()와 달리 request time에 두개의 per-directory 설정정보가 하나의 디렉토리에 적용될 때, 사용됩니다. 두개의 설정정보가 하나로 합쳐서 새로운 설정정보로 만들어지고, 새로운 설정에 따라 결과가 처리되는 것입니다.
이상, 환경설정에 관련된 아파치 API 함수 4개 알아봤습니다.
그 다음은 command_rec관해 알아봅시다.
원형을 보게되면,
typedef struct command_struct
{
const char *name;
/* 명령어의 이름 */
const char *(*func) ();
/* 호출될 함수 */
void *cmd_data;
/* 복수의 명령어를 갖는 함수를 위한 데이터 */
int req_override;
/* What overrides need to be allowed to enable this command.*/
enum cmd_how args_how;
/* 구체적 설정을 위한 값들 */
const char *errmsg;
/* syntax 에러시, 메세지 */
} command_rec;
mod_alias 의 경우를 보겠습니다. mod_alias는 다음과 같이 command_rec구조체에 정보를 입력합니다.
static const command_rec action_cmds[] =
{
{"Action", add_action, NULL, OR_FILEINFO, TAKE2,
"a media type followed by a script name"},
{"Script", set_script, NULL, ACCESS_CONF | RSRC_CONF, TAKE2,
"a method followed by a script name"},
{NULL}
};
Action, Script는 실제로 httpd.conf를 열어보면 볼 수 있을 겁니다.
그리고 이 단어들은 httpd.conf의 어느 위치에 와도 상관이 없습니다.
이런 정보는 어디에 있느냐?
세번째 인자값에 OR_FILEINFO라구 적혀있죠? 그것이 command명령어의 범위를 나타내 줍니다.
구체적인 건 밑에 적어놨습니다.
{"Action", add_action, .., OR_FILEINFO, TAKE2,..}
Action 이란 단어가 httpd.conf에 보이면 이것을 처리할 함수를 찾아야 하죠.그 함수는 여기서 add_action이 됩니다.
그리고 add_action 함수는 2개의 인자값을 취하게 되네요..
인자값 개수는 어떻게 알았냐면 TAKE2라고 적혀있는 부분이 그것을 알려줍니다. 인자값이 한개이면 TAKE1이라고 적어주세요~
그리고 만약 세개가 필요하다면 TAKE3라고 적어주시면 됩니다.
좀전에 OR_FILEINFO와 같이 범위설정하는 거 있었죠?
command_rec 구조체에 정수형으로 정의된 req_overide인데,
이 값은 다음과 같은 값을 갖습니다.
RSRC_CONF
The directive can only be present in the server .conf files, outside of, , and containers. Not allowed in any .htaccess files or other files defined by the AccessFileName directive.
ACCESS_CONF
The directive can only be present in the server .conf files, inside, , and sections. It is not allowed in .htaccess files.
OR_AUTHCFG
The directive has the same scope as ACCESS_CONF, but it is also allowed in .htaccess if AllowOverride AuthConfig is configured for the current directory.
OR_LIMIT
The directive has the same scope as ACCESS_CONF, but it is also allowed in .htaccess if AllowOverride Limit is configured for the current directory.
OR_OPTIONS
The directive is allowed anywhere in the .conf files, and it is also allowed in .htaccess if AllowOverride Options is configured for the current directory.
OR_FILEINFO
The directive is allowed anywhere in the .conf files, and it is also allowed in .htaccess if AllowOverride FileInfo is configured for the current directory.
OR_INDEXES
The directive is allowed anywhere in the .conf files, and it is also allowed in .htaccess if AllowOverride Indexes is configured for the current directory.
OR_ALL
The directive can be just about anywhere it wants to be.
OR_NONE
The directive cannot be overridden by any of the AllowOverride options.
The directive can only be present in the server .conf files, outside of
ACCESS_CONF
The directive can only be present in the server .conf files, inside
OR_AUTHCFG
The directive has the same scope as ACCESS_CONF, but it is also allowed in .htaccess if AllowOverride AuthConfig is configured for the current directory.
OR_LIMIT
The directive has the same scope as ACCESS_CONF, but it is also allowed in .htaccess if AllowOverride Limit is configured for the current directory.
OR_OPTIONS
The directive is allowed anywhere in the .conf files, and it is also allowed in .htaccess if AllowOverride Options is configured for the current directory.
OR_FILEINFO
The directive is allowed anywhere in the .conf files, and it is also allowed in .htaccess if AllowOverride FileInfo is configured for the current directory.
OR_INDEXES
The directive is allowed anywhere in the .conf files, and it is also allowed in .htaccess if AllowOverride Indexes is configured for the current directory.
OR_ALL
The directive can be just about anywhere it wants to be.
OR_NONE
The directive cannot be overridden by any of the AllowOverride options.
4개의 API함수, command_rec구조체 등에 대해 간단히 알아봤습니다. 다음 장에서 간단한 예제파일을 보면서 설명하겠습니다.