** httpd.confによるBasic認証の設定 [#q3877d13]

- 「htpasswd」プログラムを実行し認証に使用したいユーザのログイン名[username]をユーザ管理ファイル「.htpasswd」に設定する
~ ※セキュリティ上公開されていないディレクトリに保存。コマンドオプション「-c」は新規でファイル作成の意味
 # htpasswd -c /etc/httpd/conf/.htpasswd [username]
 New password:
 Re-type new password:
 Adding password for user [username]

- Apache設定ファイルの最終行に以下を追記しBasic認証を有効化
 # vi /etc/httpd/conf/httpd.conf
 
 <Directory "/var/www/html">  # Basic認証を設定したいディレクトリパスを記述
         AuthUserFile /etc/httpd/conf/.htpasswd # 認証ユーザの設定ファイルパスを記述
         AuthGroupFile /dev/null
         AuthName "Please Enter Your Password"
         AuthType Basic
         Require valid-user
 </Directory>

- Apacheを再起動
 # /etc/init.d/httpd restart


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS