CentOS 7
Sponsored Link

Enable Basic Authentication
Enable Basic Authentication to limit access on specific web pages.
[1] For example, set Basic Authentication setting under the directory [/var/www/html/auth-basic].
[[email protected] ~]#
vi /etc/httpd/conf.d/auth_basic.conf
# create new

<Directory /var/www/html/auth-basic>
    AuthType Basic
    AuthName "Basic Authentication"
    AuthUserFile /etc/httpd/conf/.htpasswd
    require valid-user
# add a user : create a new file with "-c" ( add the "-c" option only for the initial registration )

[[email protected] ~]#
htpasswd -c /etc/httpd/conf/.htpasswd cent

New password:
# set password

Re-type new password:
# confirm

Adding password for user cent
[[email protected] ~]#
systemctl restart httpd
[[email protected] ~]#
mkdir /var/www/html/auth-basic

[[email protected] ~]#
vi /var/www/html/auth-basic/index.html
# create a test page

<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Test Page for Basic Auth
[2] Access to the test page from a client computer with a web browser. Then authentication is required like follows as a setting, answer with a user added in [1].
[3] Just accessed.