何度もやっているのだが、たまにしか行わないために覚え書き。
まずは、httpd設定ファイルへの設定。
http://xxx.xxx.xxx/hoge へアクセスする場合の設定となる。
$ mv /etc/httpd/conf.d/ $ vi hoge.conf <Location /hoge> AuthType Basic AuthName "Whoocus" AuthUserFile /etc/httpd/auth_file/.hoge_passwd_file # パスワードファイルの場所 Require valid-user </Location>
そして、パスワードファイルの作成
新規にパスワードファイルを作成する場合は -c オプションを付加する。
$ htpasswd -c /etc/httpd/auth_file/.hoge_passwd_file whoocus New password: ***** Re-type new password: *****
Webサーバの再起動。
$ /etc/rc.d/init.d/httpd restart
これでBasic認証の設定完了。