tomo.gif (1144 ツバツイツト)line.gif (927 ツバツイツト)line.gif (927 ツバツイツト)To previous pageTo home pageMailing to me

パスワードを入れないと開けないようにする

Modified: 23 December 2002


"/etc/httpd/conf/httpd.conf" の変更

以下のように、"AllowOverride none"を、"AllowOverride AuthConfig"に変更します。

       :
       :

<Directory "/var/www/html">

#
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
    Options Indexes FollowSymLinks

#
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
    AllowOverride AuthConfig

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all
</Directory>

       :
       :


"/var/www/.htpasswd" の作成

最初は、新規ファイル作成を意味する "-c"オプションをつけて実行し、2回目以降は、"-c"を付加せずに実行する。

# cd /var/www
#
# htpasswd -c .htpasswd tomo
New password: ******
Re-type new password: ******
#
# htpasswd .htpasswd hiro
New password: ******
Re-type new password: ******
#

".htpasswd"のファイルは、機能上はどこに置いてもいいですが、公開するディレクトリである、"/var/www/html"以下には置かないほうが安全です。


".htaccess"

パスワードを入れさせたい(アクセス制限させたい)フォルダ内に、以cd下の内容で作成します。

AuthType Basic
AuthName "Please have to enter username and password"
AuthUserFile /var/www/.htpasswd
AuthGroupFile /dev/null
<Limit GET POST>
  require valid-user
</Limit>

To previous pageTo home pageMailing to meJump to Top of pageline.gif (927 ツバツイツト)tomo.gif (1144 ツバツイツト)