Add a password to the Apache directory under the Linux operating system

  
Instance one:
Allow a user to access a directory 1. Use htpasswd to create a user file: $ htpasswd -c /data/httpd/secr/.htpasswd user This program will ask the user for the "user1" password. You type "passwd" and it takes effect twice. 2. Create a .htaccess file and use the "vi /log/image/www/huodong/erge/admin/.htaccess" command to create a .htaccess file and write the following lines: AuthName My Friend Only (Note: This name is optional) AuthType Basic AuthUserFile /data/httpd/secr/.htpasswd require user user Finally set the file permissions of the .htpasswd and .htaccess files to ensure that the Apache user has read access and thus complete the work of setting the password for the webpage. 3. Modify the httpd.conf file: Use the "vi /data/httpd/conf/httpd.conf" file and add a few lines: Options Indexes FollowSymLinks AllowOverride authconfig Order allow,deny Allow from all # #AccessFileName .htpaccess #AllowOverride ALL # < B> Instance 2:
Allows a group of users to access a directory. The m1 and m2 users in the myfriend group can access the pages in the /home/httpd/html/backup/directory using the passwords "m1pass" and "m2pass" respectively. Implementation steps: 1. Use htpasswd to create a user file, and enter the passwords "m1pass" and "m2pass" for the two users m1 and m2 respectively in the prompt: htpasswd -c /home/httpd/secr/.htpasswd m1 htpasswd -c /home/httpd/secr /.htpasswd m2 2. Create a group file, use the "vi /home/httpd/secr/.htgroup" command to create a .htgroup file and write the following line: myfriend:m1 m2 3. Create a .htaccess file with the "vi /home/httpd/html/backup/.htaccess" command and write the following lines: AuthName My Friend Only AuthType Basic AuthUserFile /home/httpd/secr/.htpasswd AuthGroupFile /home/httpd /secr/.htgroup require group myfriend

Copyright © Windows knowledge All Rights Reserved