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 verification. As long as you step by step, you can easily implement user verification.
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 verification. As long as you step by step, you can easily implement user verification.
You must have installed Apache.
Step 2:
Create a test directory under/var/www (apache homepage root directory,
mkdir /var/www/test
Step 2:
Then we compile httpd. conf and add,
Alias/test'/var/www/test'
Options Indexes MultiViewsAllowOverride AuthConfig # identity verification Order allow, denyAllow from all
AllowOverride AuthConfig performs identity authentication, which is a critical setting.
Step 2:
Created in/var/www/test. htaccess file vi/var/www/test /. htaccessAuthName 'Frank share web' AuthType Basic AuthUserFile/var/www/test /. htpasswdrequire valid-user # AuthName description, write # AuthUserFile/var/www/test/at will /. 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, the security factor will be higher.
Step 2:
Is the authentication user who created apache.
htpasswd -c /var/www/test/.thpasswd frank
The first time you create a user, you need to use the-c parameter to add the user 2nd times without the-c parameter. If you want to modify the password, you can:
htpasswd -m .htpasswd frank
Step 2:
Restart the Apache service and visit 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 do not recommend applying AllowOverride AuthConfig or AllowOverride ALL for the sake of server performance, because this will keep the server searching. htaccess, which affects the efficiency of the server. generally, we need to verify this requirement for some background governance interfaces or other special directories.