Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure apache in Linux server to support user authentication

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to configure apache in the Linux server to support user authentication. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Apache supports user authentication

For the security of the server, when a user requests access to a folder, Apache can require the user to enter a valid user name and login password

1. Create a test directory

[root@localhost cgi-bin] # mkdir / var/www/html/wj

2. Enable the authentication function, and modify the configuration file httpd.conf as follows, (change none to all in the configuration of the html directory)

[root@localhost ~] # gedit / etc/httpd/conf/httpd.conf

# AllowOverride controls what directives may be placed in .htaccess files.

# It can be "All", "None", or any combination of the keywords:

# Options FileInfo AuthConfig Limit

#

AllowOverride All / / defaults to none, and here it is changed to all

#

# Controls who can get stuff from this server.

#

Order allow,deny

Allow from all

3. Add the configuration to the directory that needs authentication, modify the httpd.conf file, and add the following

/ / wj is the directory we want to authenticate.

AllowOverride AuthConfig / / AuthConfig must be used here

Order allow,deny

Allow from all

4. Set the user name and password to the test directory

[root@localhost wj] # htpasswd-c / var/www/html/wj/.htpasswd david / / david is the user name created

New password: / / you need to enter the password here. The following is the confirmation password.

Re-type new password:

Adding password for user david / / created successfully

[root@localhost wj] #

5. Create a htaccess file and add content

[root@localhost wj] # vim .htaccess

AuthUserFile / var/www/html/wj/.htpasswd

AuthName "david"

AuthType Basic

Require valid-user

6. Restart the Apache service

[root@localhost wj] # service httpd restart

7. Test. Type "127.0.0.1/wj" in the browser, and you can see that you need to enter a password.

A Linux learning platform has been made, and a prototype has come out at present, which you can refer to and use.

Link: https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ password: n7bk

The above content is how to configure apache to support user authentication in the Linux server. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report