Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Apache user authentication

Shulou Source: shulou.com Published: 2022-06-01 05:59:16 11月25日 Update

After setting up the LAMP environment and installing Discuz, how to use the user authentication function of Apache, this function will create a page only, which can only be accessed after entering the password! The command operates as follows:

Cd / data/www

Mkdir abc

Cd abc

Cp / etc/passwd. / 12.txt

Vim / usr/local/apache2/conf/extra/httpd-vhosts.conf (insert the following information before the last line)

Allowoverride AuthConfig

AuthName "Custom"

AuthType Basic

AuthUserFile / data/.htpasswd

Require valid-user

# "Custom" is the password prompt for the pop-up window of a web page

Save exit

Vim / etc/profile.d/path.sh (add the following information at the end)

: / usr/local/apache2/bin/

Save and put forward

Source / etc/profile.d/path.sh

Htpasswd-c / data/.htpasswd user1 (- c stands for creation, and again, use this command to create users without adding-caches! It will be covered! )

Cat / dat/.htpasswd

Htpasswd / data/.htpasswd user2

Cat / dat/.htpasswd

Apachectl-t

Apachectl graceful

Browse www.test.com/abc/12.txt

Vim / usr/local/apache2/conf/extra/httpd-vhosts.conf

Tags: User information function command password authentication one line representative will create again only environment end web page page prompt browse enter Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB OPPO Reno Shulou Information Apple Huawei