[Apache] ベーシック認証設定について覚書

1 min read
Apache
hiroweb developer

個人的な防備録です。

# htpasswd -c /ファイルを置くパス/.htpasswd username(usernameという名前のユーザ)

⇒ パスワードに何を設定するか訊かれる。

httpd.conf(/etc/httpd/conf/httpd.conf)に以下を追加する。

<Directory "認証を行うディレクトリ">
   AuthType Basic
   AuthName "認証の名前"
   AuthUserFile /さっき作ったファイルを置いてあるパス/.htpasswd
   Require user username
</Directory>

最後に httpd を再起動する。

# service httpd restart