When you log in to the site, we can implement user-based authentication, and of course, based on a single user and group, configuration is similar, testing this feature:
Get ready:
Centos6.3 virtual machine,IP address:172.16.100.3, has been configured Yum source and can surf the internet in order not to affect the effect, you can first shut down the firewall and SElinux
To start the test:
1. Install the necessary packages
Yum-y Install httpd
2. Simple configuration, and turn on this service
a) [[email protected] ~]# vim/etc/httpd/conf/httpd.conf
Search:/#ServerName
Add servername localhost:80
b) [[email protected] ~]# cd/var/www/html/
Edit a Web page file named index.html here to customize the content
c) [[email protected] ~]# service httpd start
3. Open the browser, Access 172.16.100.3, can access to the customized page content
4. Edit the configuration file and add the appropriate configuration
[Email protected] ~]# vim/etc/httpd/conf/httpd.conf
Modify and add the following in the <directory "/var/www/html" > section
AllowOverride authconfig
AuthType Basic
AuthName "Restricted Site ..."
AuthUserFile "/ETC/HTTPD/CONF/HTPASSWD"
Require Valid-user
5. Create two users and create an authenticated user file when creating the first user
[Email protected] ~]# htpasswd-c-m/etc/httpd/conf/htpasswd Hadoop
[Email protected] ~]# htpasswd-m/etc/httpd/conf/htpasswd fsy
6. Check the configuration file for syntax errors, if correct, restart
[Email protected] ~]# httpd-t
[Email protected] ~]# service httpd restart
7. In the browser test can
Test success!
Other ways to modify the configuration file:
Based on individual user authentication:
AllowOverride authconfig
AuthType Basic
AuthName "Custom "
AuthUserFile "/ETC/HTTPD/CONF/HTPASSWD"
Require User Username
Based on user group authentication:
AllowOverride authconfig
AuthType Basic
AuthName "Custom "
AuthUserFile "/ETC/HTTPD/CONF/HTPASSWD"
authuserfile "/etc/httpd/conf/htgroups "
Require Group Name
Edit the Htgroups file to add :
Group name User name (note that the user name is separated by a space)
This article is from the "10917734" blog, please be sure to keep this source http://10927734.blog.51cto.com/10917734/1844473
Implementation of Web service authentication