One day, I suddenly found that the configured HTTP server was used by many unidentified people on the Internet. So I thought about configuring an authentication and the configuration was successful in accordance with [configuration verification] actual Apache user verification. There are three main steps:
1. modify the contents of the Directory section in the httpd. conf file.
1 <directory "/data/movies/">
2 indexoptions charset = gb2312
3 options indexes followsymlinks
4 AllowOverride authconfig
5 order allow, deny
6 allow from all
7 </directory>
The AllowOverride entry of Row 3 must be set to authconfig to allow. the authentication command in the htaccess document, of course, can be set to all to execute. all configurations in htaccess; none is ignored. htaccess document.
This is not the same as above.
2. Create a. htaccess file under the directory to be authenticated. There are two ways to save authentication information:
1. Users and group files must be stored in text data. The file generation method is described in step 1.
1 authname "Password File auth"
2 authuserfile/opt/apache2/CONF/Password
3 authgroupfile/opt/apache2/CONF/group
4 require group FTP
2. Save it to the database. The generation method is described in step 1.
1 authname "DB auth"
2 authdbuserfile/opt/apache2/CONF/dbuser. dat
3 require username1
3. Create a password file to generate authentication information. There are two methods:
I. user and group file Methods,
1. If you generate a user file, you will be prompted to enter the password.
1/opt/apache2/bin/htpasswd-C/opt/apache2/CONF/password username1
2/opt/apache2/bin/htpasswd/opt/apache2/CONF/password username2
2. Create a New/opt/apache2/CONF/group file in the group file. The content is as follows:
1 ftp: username1 username2
Ii. Database Methods
1/opt/apache2/bin/dbmmanage/opt/apache2/CONF/dbuser. dat adduser username1
Now, the basic configuration is complete and can be used. Note that you can set multiple groups in the group file, and then specify different groups in the. htaccess file under the directory that requires different authentication to control different users to access different directories.