1. Configure user authentication for a virtual host
Requirement: User access to 123.txt files in/DATA/WWW/ABC directory requires authentication
[Email protected] www]# mkdir ABC
[[Email protected] www]# CD ABC
[Email protected] abc]# cp/etc/passwd 123.txt
[Email protected] abc]# vim/usr/local/apache2/conf/extra/httpd-vhosts.conf
In the corresponding virtual host configuration file segment, add the following code (Chinese note, do not add, otherwise will be error)
<directory/data/www/abc>
allowoverride authconfig
AuthName "Custom"
authtype basic
require VALID-USER
</directory
650) this.width=650; "title=" 1.png "alt=" wkiom1xi8ruzia-waahmrqnwbx4559.jpg "src=" http://s3.51cto.com/wyfs02/M01/ 72/68/wkiom1xi8ruzia-waahmrqnwbx4559.jpg "width=" 650 "style=" Padding:0px;margin:0px;vertical-align:top;border: none; "/>
After saving, then create an Apache authenticated user
[Email protected] abc]#/usr/local/apache2/bin/htpasswd-c/data/.htpasswd TPP
The first time to create a user TPP to use the-c parameter, the 2nd time to add the user, do not use the-c parameter, because-C is the meaning of the creation, if added will put this file rewrite.
New Password:
Re-type New Password:
Adding Password for user TPP
[Email protected] abc]#/usr/local/apache2/bin/apachectl-t
Syntax OK
[Email protected] abc]#/usr/local/apache2/bin/apachectl restart
Then we'll visit the next
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/8F/wKiom1ciMK_yRuIzAACzKs38KbY360.png "title=" 1111. PNG "alt=" Wkiom1cimk_yruizaaczks38kby360.png "/>
The above is garbled, is a character set problem, because the configuration file written "Custom", we can write in English.
This article is from "Linux rookie" blog, please be sure to keep this source http://490617581.blog.51cto.com/11186315/1768849
Apache user authentication