apache登陆验证
Set up Apache login password, verify one, edit the virtual directory configuration file, and set the authentication method
Alias /test "/var/www/test""
Options Indexes MultiViews
AllowOverride AuthConfig said # authentication
Order, allow, deny
Allow from all
Two, create a.Htaccess file in the web directory
VIM /var/www/test/.htaccess
AuthName "test" # described here, but after the experiment, if you want to set the virtual directory name
AuthType Basic authentication type
The path AuthUserFile /var/www/test/.htpasswd # password file
Require valid-user
# password file.Htpasswd is recommended, because the default Apache system of ".Ht" at the beginning of the file does not allow external access, safety factor will be a little higher.
The last "require" of the #.htaccess file tells the server what users can access. "Require valid-user" means that any one of the.Htpasswd can enter. You can also specify that someone or a few people on the list can pass by using require user username or require user username1 username2 username3. You can also specify that a group of people can pass, using require group groupname.
file right
-rw-r--r--.Htaccess
-rwxr--r--.Htpasswd # password file without RWX permission, may have failed to verify
Three, create user password
Is the validation user that created the Apache
Htpasswd -c /var/www/test/.htpasswd user name
# first create the user to use the -c parameter second add users without -c parameters
Htpasswd -m.Htpasswd username change password
Htpasswd -D.Htpasswd user name delete user
/*------------------------------------------------------
PS can also boil down the 1,2 step to the same step, as follows:
Alias /test "/var/www/test""
Options Indexes MultiViews
AuthType basic # type
AuthName "welcome test""
AuthUserFile /var/www/test/.htpasswd # encrypted configuration file path
Require valid-user = user, test, #test is the user name, if there are other users listed after test
# Order allow, deny
# Allow from all
--------------------------------------------------------*/
Restart Apache, OK! Restart method: Service httpd restart
Four, access through user groups
Alias /test01 "/data/web/test01/""
Options Indexes MultiViews
AuthType basic
AuthName "welcome test""
AuthUserFile /etc/httpd/httppwd
AuthGroupFile /etc/httpd/httpgrp # user group file path
Require group admin #admin is the user group
Creating a user group configuration file
The same VI /etc/httpd/httpgrp # create the specified file path and configuration file
The contents are as follows: admin:test # note that test is a good user has been created, if there are other users in the group, once arranged in space
Restart Apache ok!
2,
Apache username and password login settings 2012-10-29 15:48:41| classification: Linux | Tags: | name and subscription.
Apache authentication security configuration, access to resources, pop-up login box requires user name password
In 1: httpd.conf, you set the directory for authentication
Options Indexes FollowSymLinks
AllowOverride AuthConfig
Order, allow, deny
Allow from all
2: to directory /home/mrtg/html, increase.Htaccess
AuthName "passwd, sir."!"
AuthType Basic
AuthUserFile /home/mrtg/html/.htpasswd
Require valid-user
Popup window prompt passwd, sir
Parse the password file "/home/mrtg/html/.htpasswd", start with ".Ht", "Apache", "Web" is not allowed to access
The valid-user password file matches the user through
If it is require Bruce, only the Bruce user passes
3: uses the admin name, password, and MD5 saved under the apache/bin directory
/home/mrtg/html/.htpasswd
Create new file and add user /apache/bin/htpasswd -c /home/mrtg/html/.htpasswd MRTG
Will prompt for a password
Increase user /apache/bin/htpasswd /home/mrtg/html/.htpasswd mrtg2
Change password /apache/bin/htpasswd, -m,
/home/mrtg/html/.htpasswd, MRTG
Restart Apache will take effect.