Apache server implements User Authentication

Source: Internet
Author: User
Article Title: apache server implements user verification. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The apache server has a built-in user authentication mechanism. If you set it appropriately, you can control some parts of the website for user authentication. As long as you follow me step by step, you should be able to easily implement user verification.
  
   Step 2:
  

Create a test directory under/var/www (apache homepage root directory ).
  
Mkdir/var/www/test
  
   Step 2
  
Then edit httpd. conf.
  
Add
Alias/test "/var/www/test"
  
Options Indexes MultiViews
AllowOverride AuthConfig # indicates authentication.
Order allow, deny
Allow from all
  
  
# AllowOverride AuthConfig indicates authentication. This is the key setting.
  
   Step 2
  
Create a. htaccess file in/var/www/test
Vi/var/www/test/. htaccess
  
AuthName "frank share web"
AuthType Basic
AuthUserFile/var/www/test/. htpasswd
Require valid-user
  
# Description of AuthName, which can be written at will
# AuthUserFile/var/www/test/. htpasswd
# Require valid-user or require user frank
  
# We recommend that you use. htpasswd for password files, because apache does not allow external reading of files starting with ". ht" by default, and the security factor will be higher.
  
   Step 2
  
Is to create an apache user authentication
  
Htpasswd-c/var/www/test/. htpasswd frank
  
# If the-c parameter is used to add a user for the first time, the-c parameter is not used.
  
If you want to change the password, you can:
  
Htpasswd-m. htpasswd frank
  
   Step 2:
  
OK. Restart the apache service and access http: // your website address/test. If the problem persists, a pop-up window for user verification should be displayed, enter the username and password created in step 1.
  
Later, we generally do not recommend AllowOverride AuthConfig or AllowOverride ALL for the sake of server performance, because this will enable the server to continue searching. htaccess affects the server performance. Generally, we need to verify the performance of some background management interfaces or other special directories.

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.