Set apacheweb server password authentication

Source: Internet
Author: User

Set apacheweb server password authentication

Go straight to the topic !!!

1. You need to modify the main configuration file of httpd. It is installed in/etc/httpd/conf/httpd. conf by default.

2. vi edit this file

3. Several lines of code need to be modified

Find And To modify the information.

A. Change AllowOverride None to AllowOverride AuthConfig.

B. Add AuthType Basic

C. Add AuthName "My private website ..."

D. Add the User File AuthUserFile "/etc/httpd/conf/htpasswd"

E. Add the User Require user tom jerry (if you want users in htpasswd to have access, change it to Require valid-User)

4. Create a password file

# Htpasswd-c-m/etc/httpd/conf/htpasswd tom

Enter the tom password twice as prompted, and then create the jerry user.

# Htpasswd-m/etc/httpd/conf/htpasswd jerry

Note:-c cannot be used here, because-c Indicates creating a password file. It is only required if there is no password file. If there is a password file, the original one will be deleted directly, in addition,-m indicates that the added user has been encrypted in MD5 mode.

If you delete a user, use the-D option, for example, # htpasswd-D/etc/httpd/conf/htpasswd tom.

5. Restart the web Service

# Service httpd restart

The above section describes how to create a user password, that is, to restrict some users. In fact, httpd also supports group restrictions. The following section describes how to create a user password --------------------

If you want to perform operations on a group, do the following:

 

1. You need to modify the main configuration file of httpd. It is installed in/etc/httpd/conf/httpd. conf by default.

2. vi edit this file

3. Several lines of code need to be modified

Find And To modify the information.

A. Change AllowOverride None to AllowOverride AuthConfig.

B. Add AuthType Basic

C. Add AuthName "My private website ..."

D. Add the User File AuthUserFile "/etc/httpd/conf/htpasswd"

E. Add the group file AuthGroupFile "/etc/httpd/conf/htgroup"

F. Add the Require group mygroup1 mygroup2

4. Create a password file

# Htpasswd-c-m/etc/httpd/conf/htpasswd tom

Enter the tom password twice as prompted, and then create the jerry user.

# Htpasswd-m/etc/httpd/conf/htpasswd jerry

Note:-c cannot be used here, because-c Indicates creating a password file. It is only required if there is no password file. If there is a password file, the original one will be deleted directly.

5. Create a group file

# Vim/etc/httpd/conf/htgroup

(Add the content to the file)

Mygroup1: tom jerry

Mygroup2: tom

Save and exit. Note that the user must exist in the password file.

6. Restart the web Service

# Service httpd restart

Now you can see that you need to enter the verification password.

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.