How To Configure Apache Web Page Authentication on Ubuntu / Debian

Windows Articles

How to install Django on Ubuntu 20.04?

Developing web applications is usually related to PHP frameworks. However, Python, which is a very versatile programming language, also has a framework...

How to install the Development and build tools on Ubuntu 20.04?

In this very short post, you will learn how to install a series of development and build tools on Ubuntu 20.04. These...

How to set a drive as read-only in Windows 10

Hello! Hard drives are a fundamental element in any operating system. Of course, Windows 10 is no exception. In fact, this is...

How to create a new KVM virtual Machine on Debian 10?

In the previous post, we explained how to install KVM on Debian 10. Now it's time to create a KVM Virtual Machine.

How to repair a USB drive in Windows 10.

Hi! USB sticks are undoubtedly very functional elements for working in Windows 10. Indeed, their use ranges from file management to creating...

How can I secure an Apache Web page with password authentication on Ubuntu / Debian Web Server? How to use fundamental Authentication to restrict entry to specific Web pages on Apache? After installing and configuring your Apache Web Server, you need to configure password Authentication for a web page. This manual will cover a way to Install a password protected directory using fundamental Authentication. So, we will cover how to Configure Apache Web Page authentication on Ubuntu / Debian.

Apache Web Server can be set up on Ubuntu or Debian Server / Laptop by using firing the command below.

sudo apt update 
sudo apt -y install apache2

Check that Apache is running.

systemctl status apache2

You’ll see the following web page on the Server’s IP address/Host name.

Basic Apache Web Server Authentication Configuration

As you’ve installed Apache Web Server, now install Basic Authentication packages.

sudo apt -y install apache2-utils pwauth libapache2-mod-authnz-external 

Then create new configuration file for Apache under /etc/apache2/sites-available directory. And do the same as below.

sabi@Ubuntu:~$ sudo tee /etc/apache2/sites-available/secure-page.conf<<EOF
><Directory /var/www/html/secured>
>AuthType Basic
>AuthName "Basic Authentication"
>AuthUserFile /etc/apache2/.htpasswd
>require valid-user
></Directory>
>EOF

Then add users to the Basic Authentication file.

sudo htpasswd -c /etc/apache2/.htpasswd webuser
New password:
Re-type new password:
Adding password for user webuser

We use the -c option for the initial configuration, for next time we use:

sudo htpasswd -c /etc/apache2/.htpasswd osradar
New password:
Re-type new password:
Adding password for user osradar

Below file with users will be look like

cat /etc/apache2/.htpasswd

Now, it’s time to enable secure web. Run the command and you’ll see the following results

sudo a2ensite secure-page
Enabling site secure-page.
To activate the new configuration, you need to run:
systemctl reload apache2

Then create secure web directory.

sudo mkdir -p /var/www/html/secured

And then add the below data just for test purposes.

sudo tee /var/www/html/secured/index.html<<EOF
<html>
<body>
<div style="width: 100%; font-size: 50px; font-weight: bold; text-align: center;">
My secure web page - Using Basic Auth
</div>
</body>
</html>
EOF

Then restart Apache Services.

sudo systemctl restart apache2

After restarting apache services, test the web page to make sure that it is secure. So, type the below address in URL of browser.

localhost/secure

Or you can also use your IP address.

You will be asked to provide details as you have enter.

Then you’ll be directed to the secure Web Page.

So, this is how we can configure Apache Web Page Authentication.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to install Django on Ubuntu 20.04?

Developing web applications is usually related to PHP frameworks. However, Python, which is a very versatile programming language, also has a framework...

How to install the Development and build tools on Ubuntu 20.04?

In this very short post, you will learn how to install a series of development and build tools on Ubuntu 20.04. These...

How to set a drive as read-only in Windows 10

Hello! Hard drives are a fundamental element in any operating system. Of course, Windows 10 is no exception. In fact, this is...

How to create a new KVM virtual Machine on Debian 10?

In the previous post, we explained how to install KVM on Debian 10. Now it's time to create a KVM Virtual Machine.

How to repair a USB drive in Windows 10.

Hi! USB sticks are undoubtedly very functional elements for working in Windows 10. Indeed, their use ranges from file management to creating...