2014年9月1日月曜日

centos apache httpd.conf Directory 設定 2 Basic認証

basic認証。

/etc/httpd/conf/に作った.htpasswdファイルの内容を
/etc/httpd/conf/httpd.conf
または
/etc/httpd/conf.d/*.conf
の設定で反映させたい所に反映させる方法。

新しく.htpasswdファイルを作成する場合
#htpasswd -c -b /etc/httpd/conf/.htpasswd user1 password

既にある.htpasswdファイルにユーザを追加する場合
#htpasswd -b /etc/httpd/conf/.htpasswd user2 password


/etc/httpd/conf/httpd.conf
または
/etc/httpd/conf.d/*.conf
に設定を書く。
<Directory "/var/www/html/hogebasic">

AuthUserFile /etc/httpd/conf/.htpasswd
      AuthGroupFile /dev/null
      AuthName "Basic Auth"
      AuthType Basic
      Require valid-user

#    AllowOverride All
      AllowOverride None

      Order allow,deny
#     Allow from 192.168.1.
      Allow from all
</Directory>

設定変更後の再起動
/etc/rc.d/init.d/httpd restart

0 件のコメント:

コメントを投稿