※Webサーバーは.htaccessを許可設定済みとする。
目次 |
[root@host2 ~]# htpasswd -b -c /etc/httpd/conf/.htpasswd sudachi sudachipassword
← .htpasswdを作成してユーザーsudachiを登録する Adding password for user sudachi
[root@host2 ~]# htpasswd -b /etc/httpd/conf/.htpasswd sudachi sudachipassword
← 既存の.htpasswdへユーザー sudachiを登録する Adding password for user sudachi
[root@host2 ~]# cat /etc/httpd/conf/.htpasswd ← ユーザー登録確認 sudachi:syipeg7crzq9c
.htpasswdに登録してある全てのユーザー名で認証できるようにする場合
[root@host2 ~]# vi /var/www/html/sudachi/.htaccess ← テスト用ディレクトリに.htaccess作成 SSLRequireSSL AuthUserFile /etc/httpd/conf/.htpasswd AuthGroupFile /dev/null AuthName "secret page" AuthType Basic require valid-user
.htpasswdに登録してある特定のユーザー名(ここでは、認証を許可するユーザー名をsudachiとする)でのみ認証できるようにする場合
[root@host2 ~]# vi /var/www/html/sudachi/.htaccess ← テスト用ディレクトリに.htaccess作成 SSLRequireSSL AuthUserFile /etc/httpd/conf/.htpasswd AuthGroupFile /dev/null AuthName "secret page" AuthType Basic require user sudachi ← 認証を許可するユーザー名を指定