Apache Sets user authentication notes on the virtual host

Source: Internet
Author: User

Virtual Host configuration file httpd-vhosts.conf, need to join

<Directory/mysqldata/www>

AllowOverride authconfig

</Directory>

Then in the home directory of the virtual host, which is the DocumentRoot directory

Vi/mysqldata/www/.htaccess

Join

AuthName "Frank Share Web"

AuthType Basic

authuserfile/mysqldata/www/.htpasswd

Require Valid-user

After saving, and then

To create an authenticated user for Apache

Htpasswd-c-M/MYSQLDATA/WWW/.HTPASSWD Test

#第一次创建用户要用到-C parameter is added to the user for the 2nd time without the-c parameter,-m option, encryption

If you want to change your password, you can:

Htpasswd-m. htpasswd test2

Restart Apache, then.


To this, you are already configured to complete. Here's another way to do this:

##################################

VI http.conf

In the corresponding virtual host configuration file segment, add

<Directory/mysqldata/www>

AllowOverride authconfig

AuthName "Zdy"

AuthType Basic

authuserfile/mysqldata/www/.htpasswd

Require Valid-user

</Directory>

After saving, and then

To create an authenticated user for Apache

Htpasswd-c-M/DATA/.HTPASSWD Test

Control the use of FilesMatch for a page, as follows

Web site only 1.html page access requires a password, other pages can be directly accessed ...

<Directory/mysqldata/www>
Require all granted
<filesmatch 1.html>
AllowOverride authconfig
AuthName "123"
AuthType Basic
authuserfile/mysqldata/www/.htpasswd
Require Valid-user
</filesmatch>
</Directory>


Report:

Alowoverride None

#允许覆盖参数功能

Some of the parameters of the #表示是否允许额外配置文件. htaccess are overwritten. We can set all the permissions within the httpd.conf.

#不过这样一来, if the user's own personal web page wants to modify permissions, it will cause problems for administrators. As a result, Apache defaults

#可以让用户以目录下的. htaccess file covers some of the function parameters within <Direcoty>. The project is in the provision

#.htaccess What types of permissions can be overridden. The following are common:

#ALL: All permissions can be overridden

#AuthConfig: Only Web authentication (account number and password) can be overwritten

#Indexes: Allow only Indexes aspects of coverage

#Limits: Allows the user to manage Browsable permissions with Allow, Deny, and order

#None: Cannot overwrite, that is, to invalidate the. htaccess file

#使用. htaccess can seriously affect Apache performance and, if not special needs, it is recommended to close

AllowOverride: The type of instruction that is allowed in the. htaccess file (. htaccess file name can be changed and its file name is determined by the ACCESSFILENAME Directive):

None: When AllowOverride is set to none. Do not search for. htaccess files under this directory (you can reduce server overhead).

All: You can use all the instructions in the. htaccess file.



Apache Sets user authentication notes on the virtual host

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.