How to achieve the user authentication of Apache

Source: Internet
Author: User

Sometimes, we will have such a demand, that is, some files must be authenticated by the user account password to be able to access, and limit certain sites only fixed users to log in. Below, the steps to implement authentication are described in detail:

First, install the HTTPD software package, and restart the service (this is not much to say)

Second, edit/etc/httpd/conf/httpd.conf

There is a row around 330 lines in the file

"AllowOverride None" is the system default, no control list, see attached.

Here we will change none to the Authconfig parameter and add the following lines, as follows:

AllowOverride authconfig

AuthType Basic # user authentication type

AuthName "Restricted Site" # Certification when the name displayed

AUTHUSERFILE/ETC/HTTPD/CONF/HTPASSWD # Authentication When the user's account password file

Authgroupfile/etc/httpd/conf/htgroup #基于组的认证

# Require User Tom # only Tom users can log in

# Require Group Myusers # allow users in which group to log in

Require Valid-user # Users who appear in the account password file can log in

Third, create/etc/httpd/conf/htpasswd files, and users

Create a user by using the htpasswd command, add-c to create a file at the first time you create it

# htpasswd-c-M/ETC/HTTPD/CONF/HTPASSWD Tom

# htpasswd-m/ETC/HTTPD/CONF/HTPASSWD Jerry

Iv. Create group Files/etc/httpd/conf/htgroup

Write a row in a file

Myusers:tom Jerry.

Five, restart the service can be

# Service httpd Restart

Vi. Verification (local IP address is 172.16.13.1)

Can be verified locally, or in the browser.

More Wonderful content: http://www.bianceng.cn/Servers/web/

Report:

allowoverride None, default no Control list, that is, do not use user authentication, and use the following authentication mechanism: ip-based authentication.

Order Allow,deny--> Allow,deny sequence to perform its qualified precedence

Allow from all (System defaults to allow all hosts to log on)

1. If only one host is allowed to log in,

Order Allow,deny

Allow from 172.16.13.2

2, if only the rejection of a host login, then

Order Deny,allow

Deny from 172.16.13.3

Have you solved the problem? I'm glad to share my learning experience with you.

This article comes from the "Smile to the Sun" blog, please be sure to keep this source http://dongld.blog.51cto.com/4234800/1174199

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.