Linux Apache user authorization and access control

Source: Internet
Author: User
User authorization and access control you may have encountered this situation when visiting some websites. when you click a connection, your browser will pop up an authentication dialog box, the account and password are requested to be input. If no, you cannot continue browsing.

User authorization and access control

You may have encountered this situation when visiting some websites. when you click a connection, your browser will pop up an authentication dialog box requesting to enter your account and password, if not, you cannot continue browsing. Some people will think that this is done using CGI. Otherwise, this is the role of the WWW server's user authorization and access control mechanism.

Do you still remember that when you set up the Apache service environment ........ <./Directory> This Command provides different protections for different directories. However, this setting takes effect only after the server is restarted. the mobility is poor. the method for specifying the access control file through the AccessFile command is more flexible, to set a user's access control permission on the Apache server, follow these steps:

1. first, set the httpd. conf file as follows:

   
    
     
# AllowOverride FileInfo AuthConfig Limit # Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Options Includes FollowSymLinks Indexes AllowOverride All // * pay attention to AllowOverride must be set to All, so that the later. htaccess file works
     
      
Order allow, deny Allow from all
     #
     
      
# Order deny, allow # Deny from all #
      
    # Specify the file name AccessFileName. htaccess for the access control permission configuration
   

2. create an. htaccess file content

To control the access permissions of a directory, you must create a access control file. The ". htaccess" specified before the file name has the following content structure:

   
    
AuthUserFile user account password file name AuthGroupFile group account password file name AuthName screen prompt text AuthType verification method
    
     
Password verification method
    The AuthType object of the user authentication method provides two conditions: Basic and Digest. The method for setting the password test is the same as that in httpd. conf. Example: AuthUserFile/etc/secure. user AuthName security authentication center AuthType Basic
    
     
Require valid-user
    
   

3. create a user password file

If you create a user password for the first time, the command format is as follows:

Htpasswd-c password file name user name

In the above example, we put the user password file in the/etc/secure. user file, so we should hold it as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.