wikiからの移植です。
confファイルの設定
認証をかけるディレクトリディレクティブに認証をかける設定をする。
<Directory /home/hoge/...>
AllowOverride AuthConfig
</Directory>
.htaccessの設定
認証をかけるディレクトリに.htaccessを置く
AuthUserFile /home/hogehoge/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
require valid-user
AuthUserFile
.htpasswdファイルのpathを記入。ファイル名は.htpasswdでなくてもOK
AuthGroupFile
グループで認証をかける時に使用する今回はとりあえずスルー
AuthName
認証時のアラートに表示するメッセージを記入する。
日本語も使用できるが、文字コードを合わせなければいけないが、今回はこれもスルー
AuthType
BasicとDigestがある。今回はBasicを使用する。
BasicはBase64方式でエンコードされているが暗号化されてるわけじゃないので、平文で流れてしまう。
Digestの方がよりセキュアだが使用するにはmod_autu_digestモジュールがないとダメ
また、古いブラウザでIE4.X、NN4.7などでダメらしい。
require
.htpasswdにはuser名とpasswordを対にして書くが、valid-userは、指定.htpasswdに書いてある全ユーザに対して、認証が可能になる。
たとえば、1ユーザだけとかにするならば、
require user hoge
こうするとユーザhogeのみ認証することになる。
パスワードファイルの編集
書式は
username:passwrd
ここのpasswdには暗号化(DES)した文字列をつかう
wikiからの移植。私的メモです。
<VirtualHost *>
ServerName
DocumentRoot
ErrorLog
CustomLog path combined
AddDefaultCharset
</VirtualHost>
ディレクトリ ロケーション
<Directory /path>
Option +ExecCGI
</Directory>
<Location /path>
SetHandler perl-script
PerlHandler Apache::Registry
PerlInitHandler Apache::StatINC
Option +ExecCGI
PerlSendHeader On
</Location>
wikiからの移植です。
今回はsourceからbuildする。
configure
mod_perlを使う予定なのでDSOサポートでインストール
./configure --prefix=/usr/xxx... \
--enable-module=most \
--enable-shared=max
後にmod_perlを入れる時にLIBS=-lpthreadにすべきと警告があったので、以下のようにconfigureしなおす。
LIBS=-lpthread ./configure --prefix=/usr/xxx... \
--enable-module=most \
--enable-shared=max
makeとinstall
make
make install
make時のErrorについて
今回SargeにApache1.3.34を入れようとしたところ、ndbm.h No such file or directory的なErrorが出た。
gdbm-ndbm.hにリンクするように設定
ln -s /usr/include/gdbm-ndbm.h /usr/include/ndbm.h
wikiからの移植です。
今回は、apache1.3系に入れるので、mod_perlのversionは1.0を使用する
http://perl.apache.org/からdownload(今回はversion1.29)
perl Makefile.PL \
USE_APXS=1 \
WITH_APXS=/usr/local/apache/bin/apxs \
EVERYTHING=1 \
PERL_USELARGEFILES=0
make
make install