2012年8月7日火曜日

[apache]basic auth

Basic認証するメモ。

なんかこの界隈、やたらとアカパスを作成するWEBのツールあるけどなんでだろう。
もちろん、 htpasswd でやります。

. 手前味噌でげすが、http://isann.blog2.fc2.com/blog-entry-260.html の「■Basic認証アカウントを作成」を参考に。

.htpasswdファイル作成
(1).htpasswdファイルを新規作成する場合
[root@centos ~]# htpasswd -b -c /etc/httpd/conf/.htpasswd centos centospassos ← .htpasswdを作成してユーザーcentosを登録する
Adding password for user centos


(2)既存の.htpasswdファイルへユーザーを追加する場合
[root@centos ~]# htpasswd -b /etc/httpd/conf/.htpasswd centos centospassos ← 既存の.htpasswdへユーザーcentosを登録する
Adding password for user centos


(3)ユーザー登録確認
[root@centos ~]# cat /etc/httpd/conf/.htpasswd ← ユーザー登録確認
centos:vYwnFfo59lI/c

あとは、http://kensakuyoke.web.fc2.com/Basic.html を参考にさせて頂いて
.htaccess に

AuthUserFile /etc/httpd/conf/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
require valid-user(ここに改行をかならず)

こんな感じで。

0 件のコメント:

コメントを投稿