- 修改 /etc/httpd/conf/httpd.conf
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
# AllowOverride None
AllowOverride All //====修改為All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
到存取控制的目錄下新增檔案 .htaccess
vim ./htaccess
order deny,allow
deny from all
AuthName "Pop UP 視窗顯示的文字"
AuthUserFile 密碼檔案存放地
AuthType Basic
Require valid-user
Order Deny,Allow
Deny from all
Allow from 允許直接存取的網段,不需要輸入密碼
Satisfy Any
設定權限 htpasswd
第一次使用時參數為 “-c”
[root@localhost ~]# htpasswd
Usage:
htpasswd [-cmdpsD] passwordfile username
htpasswd -b[cmdpsD] passwordfile username password
htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
-c Create a new file.
-n Do not update file; display results on stdout.
-m Force MD5 encryption of the password.
-d Force CRYPT encryption of the password (default).
-p Do not encrypt the password (plaintext).
-s Force SHA encryption of the password.
-b Use the password from the command line rather than prompting for it.
-D Delete the specified user.
[root@localhost ~]# htpasswd -c 密碼檔案存放路徑 使用者名稱
New password:
Re-type new password:
Adding password for user 使用者名稱