Sometimes, we will have such a demand, that is, some files must be authenticated by the user account password to be able to access, and limit certain sites only fixed users to log in. Below, the steps to implement authentication are described in detail:
First, install the HTTPD software package, and restart the service (this is not much to say)
Second, edit/etc/httpd/conf/httpd.conf
There is a row around 330 lines in the file
"AllowOverride None" is the system default, no control list, see attached.
Here we will change none to the Authconfig parameter and add the following lines, as follows:
AllowOverride authconfig
AuthType Basic # user authentication type
AuthName "Restricted Site" # Certification when the name displayed
AUTHUSERFILE/ETC/HTTPD/CONF/HTPASSWD # Authentication When the user's account password file
Authgroupfile/etc/httpd/conf/htgroup #基于组的认证
# Require User Tom # only Tom users can log in
# Require Group Myusers # allow users in which group to log in
Require Valid-user # Users who appear in the account password file can log in
Third, create/etc/httpd/conf/htpasswd files, and users
Create a user by using the htpasswd command, add-c to create a file at the first time you create it
# htpasswd-c-M/ETC/HTTPD/CONF/HTPASSWD Tom
# htpasswd-m/ETC/HTTPD/CONF/HTPASSWD Jerry
Iv. Create group Files/etc/httpd/conf/htgroup
Write a row in a file
Myusers:tom Jerry.
Five, restart the service can be
# Service httpd Restart
Vi. Verification (local IP address is 172.16.13.1)
Can be verified locally, or in the browser.
More Wonderful content: http://www.bianceng.cn/Servers/web/
Report:
allowoverride None, default no Control list, that is, do not use user authentication, and use the following authentication mechanism: ip-based authentication.
Order Allow,deny--> Allow,deny sequence to perform its qualified precedence
Allow from all (System defaults to allow all hosts to log on)
1. If only one host is allowed to log in,
Order Allow,deny
Allow from 172.16.13.2
2, if only the rejection of a host login, then
Order Deny,allow
Deny from 172.16.13.3
Have you solved the problem? I'm glad to share my learning experience with you.
This article comes from the "Smile to the Sun" blog, please be sure to keep this source http://dongld.blog.51cto.com/4234800/1174199