Security is a fist priority, and if you maintain data security, you have a great responsibility. If you are an administrator and want to provide access to a specific website to the user you need, who has only login information, this article will help you configure basic Apache authentication using a virtual host.
Create a virtual host for out test domain
# nano /etc/httpd/conf.d/unihost.club.conf <VirtualHost *:80> DocumentRoot /var/www/html ServerName unihost.club DirectoryIndex index.php </VirtualHost>
Create a test webpage
# nano /var/www/html/index.php <html> <body> <div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;"> Unihost.club Test Page </div> </body> </html>
Create an authentication config
# nano /etc/httpd/conf.d/auth.conf <Directory /var/www/html/> AuthType Basic AuthName "Basic Authentication" AuthUserFile /etc/httpd/conf/.htpasswd require valid-user </Directory>
Create a password for user
# htpasswd -c /etc/httpd/conf/.htpasswd unihost