Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to configure apache in Linux server to support user authentication

Shulou Source: shulou.com Published: 2022-06-01 03:22:29 10月21日 Update

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.

Tags: User authentication password configuration directory service content file input server support that is user name test skill knowledge valid concise secure successful Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Xiaomi MySQL Docker Shulou Tech Info