【サーバ】Basic認証の追加

今更ながら、ど忘れしたのでメモメモ

まずはパスワードファイル作成-cオプションは新規の時のみ

# htpasswd -c /var/www/hoge.jp/.htpasswd hoge
New password:
Re-type new password:
Adding password for user hoge

追加できたらapachの設定ファイルを設定

 <Directory "/var/web/hoge.jp/htdocs">
    Options FollowSymLinks SymLinksifOwnerMatch ExecCGI
        DirectoryIndex index.php index.html

        AllowOverride All
        Order allow,deny
        Allow from all

        AuthType Basic
        AuthName "Please Enter Your Password"
        AuthUserFile "/var/web/hoge.jp/.htpasswd"
        #AuthGroupFile "/srv/.htgroup"
        Require valid-user
 </Directory>

apach再起動で終了