簡単に言うと、Apacheのベーシック認証をPostgreSQLのデータベースを使ってやるモジュールだ。
for Apache 1.3.XX http://www.giuseppetanzilli.it/mod_auth_pgsql/
for Apache 2.0.XX http://www.giuseppetanzilli.it/mod_auth_pgsql2/
今回はApache 1.3系なので上のを使った。
後編に続くっ!
ざーっとインストールログ
wget http://www.giuseppetanzilli.it/mod_auth_pgsql/dist/mod_auth_pgsql-0.9.12.tar.gz
tar -zxvpf mod_auth_pgsql-0.9.12.tar.gz
cd mod_auth_pgsql-0.9.12
./configure --with-apxs=/usr/sbin/apxs --with-pgsql-include=/usr/include/pgsql/ --with-pgsql-lib=/usr/lib/
/usr/sbin/apxs -I /usr/include/pgsql/ -L /usr/lib -l pq -o mod_auth_pgsql.so -c mod_auth_pgsql.c auth_pgsql_shared_stub.c ←ここがmake相当
/usr/sbin/apxs -i -a -n auth_pgsql mod_auth_pgsql.so ←ここがmake install相当
rpmを使ってpostgresをインストールしている場合はディレクトリ構造が違うので、
--with-pgsql-include と --with-pgsql-lib を使ってincludeのディレクトリとlibのディレクトリをそれぞれ指定してやる必要がある。
次はhttp.confの修正。
※http.confがデフォルトのままだだとうまくmod_auth_pgsql用の設定を挟んでくれるが、
修正してるといけるか不明です。
インストーラが挟んだLoadModuleの部分はパスが間違っているので修正する。
lib/apache/mod_auth_pgsql.so => modules/mod_auth_pgsql.so
とりあえずこれでOK。
今回は.htaccessでやりたいので、.httaccessを作る。
.htaccessじゃない場合でも同じような内容をhttp.confにに挟んで書けばいけるはず。
作った内容は以下のとおり
AuthName "PostgreSQL Authenticator Test" AuthType basic
Auth_PG_host mydbserver
Auth_PG_port 5432
Auth_PG_user myusername
Auth_PG_database valid_user_db
Auth_PG_pwd_table pg_auth_test
Auth_PG_uid_field user_id
Auth_PG_pwd_field password
Auth_PG_encrypted off
<Limit GET POST>
require valid-user
Auth_PG_encryptedは、暗号化するのが面倒だったのでoffにした。
以上で完了だが、
ドキュメントを読んでると
・Auth_PG_hash_type
・Auth_PG_gid_field
・Auth_PG_pwd_whereclause
等々あり、いろいろ応用効きそうだ。
2ヶ月ほどサボってる間に元から拙い文章がさらに酷くなったぜHAHAHA ||Λ