Cent OS6でjoomlaの場合
新しく.htpasswdファイルを作成する場合
htpasswd -c -b /etc/httpd/conf/.htpasswd user1 hogehoge
<htpasswd -c -b /etc/httpd/conf/.htpasswd ユーザ名 パスワード>
既にある.htpasswdファイルにユーザを追加する場合
htpasswd -b /etc/httpd/conf/.htpasswd user2 hogehoge
vi /etc/httpd/conf/.htpasswdで確認 ユーザ名とパスが明記されているはず
:q
vi /etc/httpd/conf/httpd.conf
<Directory "/var/www/html/hogehoge/administrator"> ← Basic認証を設定したい(一般的なディレクトリ)
AuthUserFile /etc/httpd/conf/.htpasswd ← 認証ユーザーの設定ファイルのパス
AuthGroupFile /dev/null
AuthName "Basic Auth"
AuthType Basic
Require valid-user
</Directory
>
:wqして...
再起動
/etc/init.d/httpd restart