0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

apache module 覚書

Last updated at Posted at 2020-04-06

apache moduleとは?

Apacheの機能はモジュールを追加することで拡張できる。Apacheの核となる「Core」がまずあり、そこへモジュールを追加して機能を拡張する。モジュール名は慣習的に「mod_XXX」と付けられる。XXXは機能の概要名である。例えば「mod_dir」「mod_alias」「mod_setenvif」などとなる。※1
C言語で記述する。

Apache Portable Runtimeとは?

サーバと OS の 間の基本的なインターフェースの多くを提供する(訳注: OS の差を吸収する)ライブラリのセット。 APR は 独立した プロジェクトとして Apache HTTP Server と平行して開発が行われています。

C言語における移植性の確保を行ってくれる抽象レイヤーで、関数名が apr_ から始まる。
メモリプールの管理や文字列操作などなどApache Module APIで利用できていた機能を利用できる。

主要機能

apr_pools

メモリプール機能。確保した領域について明示的なfreeは不要。
http://apr.apache.org/docs/apr/1.5/group__apr__pools.html

apr_strings

C言語では複雑になりがちな文字列操作を簡単に行うことができる。
返り値の領域はメモリプールから確保される。
http://apr.apache.org/docs/apr/1.5/group__apr__strings.html

apr_tables

動的に拡張される配列などを提供
http://apr.apache.org/docs/apr/1.5/group__apr__tables.html

apxs

apacheの拡張モジュールをビルドして、インストールしてくれる。
https://kazmax.zpp.jp/apache/apache3.html

request_rec 構造体

HTTPリクエストを表現した構造体。
include/httpd.hで定義。モジュールを書く上で最もよく使う構造体。

メンバ 概要
r->handler 処理するハンドラの名称
r->content_type Content-Typeヘッダ取得
r->header_only HEADリクエストかどうか
r->pool リクエスト毎のメモリプール
r->args QUERY_STRING値
r->method_number  リクエストメソッドの数値表現?
r->headers_in リクエストヘッダ apr_table_t型
r->headers_out レスポンスヘッダ apr_table_t型
r->r->uri URI
r->filename DISK上のファイル名
http://nukin.jugem.jp/?eid=23
https://ci.apache.org/projects/httpd/trunk/doxygen/structrequest__rec.html

業務で利用された機能を追記予定

これ買えばたぶんもろもろの情報網羅

WebエンジニアのためのApacheモジュールプログラミングガイド

参考

http://apr.apache.org/
https://www.slideshare.net/shebang/apache-module-presentation
http://module.jp/cookbook/apache_api/aprize_your_project.html

※1 https://ja.wikipedia.org/wiki/Apache_HTTP_Server

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?