http://www.server-world.info/query?os=CentOS_6&p=httpd&f=12
Webdav & pam
apacheのアクセスの認証をOSのユーザで認証する方法。
・mod-auth-external
・pwauth
の2つを使う。
# yum -y install httpd-devel pam-devel
# wget http://mod-auth-external.googlecode.com/files/mod_authnz_external-3.2.5.tar.gz
# wget http://pwauth.googlecode.com/files/pwauth-2.3.9.tar.gz
# tar zxvf mod_authnz_external-3.2.5.tar.gz
# cd mod_authnz_external-3.2.5
# apxs -c mod_authnz_external.c
# apxs -i mod_authnz_external.la
# cd ..
# tar zxvf pwauth-2.3.9.tar.gz
# cd pwauth-2.3.9
# vi config.h
# 126行目:コメントにする
/* #define SHADOW_SUN
# 134行目:コメント解除
#define PAM
# 281行目:変更 ( httpd の実行IDにする )
#define SERVER_UIDS 48 /* user "apache " */
# vi Makefile
# 10行目:コメントにする
# LIB= -lcrypt
# 14行目:コメント解除
LIB=-lpam -ldl
# make
# cp pwauth /usr/local/libexec/
# chmod 4755 /usr/local/libexec/pwauth
# cd ..
# vi /etc/httpd/conf/httpd.conf
# 206行目あたりに追記
LoadModule authnz_external_module modules/mod_authnz_external.so
AddExternalAuth pwauth /usr/local/libexec/pwauth
SetExternalAuthMethod pwauth pipe
# vi /etc/pam.d/pwauth
# 新規作成
#%PAM-1.0
auth include system-auth
account include system-auth
session include system-auth
# vi /etc/httpd/conf.d/auth_pam.conf
# /var/www/html/test 配下を認証必須とする
<Directory /var/www/html/test>
SSLRequireSSL
AuthType Basic
AuthName "PAM Authentication"
AuthBasicProvider external
AuthExternal pwauth
require valid-user
</Directory>
# /etc/rc.d/init.d/httpd restart
Stopping httpd:
[ OK ]
Starting httpd:
[ OK ]
# テストページ作成
# vi /var/www/html/test/index.html
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Test Page for PAM Auth
</div>
</body>
</html>
注意点
SELinux を有効にしていると、
/usr/local/libexec/pwauth
の実行権限でエラーができるので、SELinux の権限設定をするかSELinuxを無効にする
[通知用URL]
Tweet
最終更新時間:2012年03月31日 13時54分01秒