How To Configure Apache Web Page Authentication on Ubuntu / Debian

Windows Articles

Trisquel 9.0 available

Trisquel is a GNU/Linux distribution endorsed and supported by the Free Software Foundation. This means that in addition to incorporating the Linux...

How to install PandoraFMS on CentOS 8?

Worldwide many IT infrastructures are running Linux on one of their servers. This opens the door to an endless number of different...

How to force close a program using PowerShell

Hi! We have mentioned in the past that Windows allows you to open multiple programs at once. In fact, that is one...

How to install the Owncloud desktop client Ubuntu 20.04?

In this post, You will learn how to install the Owncloud desktop client on Ubuntu 20.04. Many users and...

How to finish a task and force to close a program in Windows 10

Hello! We use numerous applications in Windows 10 on a daily basis. However, these programs can fail and crash. That is, it...

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

Trisquel 9.0 available

Trisquel is a GNU/Linux distribution endorsed and supported by the Free Software Foundation. This means that in addition to incorporating the Linux...

How to install PandoraFMS on CentOS 8?

Worldwide many IT infrastructures are running Linux on one of their servers. This opens the door to an endless number of different...

How to force close a program using PowerShell

Hi! We have mentioned in the past that Windows allows you to open multiple programs at once. In fact, that is one...

How to install the Owncloud desktop client Ubuntu 20.04?

In this post, You will learn how to install the Owncloud desktop client on Ubuntu 20.04. Many users and...

How to finish a task and force to close a program in Windows 10

Hello! We use numerous applications in Windows 10 on a daily basis. However, these programs can fail and crash. That is, it...
x