Would you like to learn how to install Apache and configure the basic authentication feature on a computer running Ubuntu Linux? In this tutorial, we are going to configure the Basic authentication feature on the Apache server.

• Ubuntu 18
• Ubuntu 19
• Ubuntu 20
• Apache 2.4.41

Equipment list

The following section presents the list of equipment used to create this tutorial.

As an Amazon Associate, I earn from qualifying purchases.

Tutorial Apache – Basic authentication

Install the Apache server and the required packages.

Copy to Clipboard

Create the Apache password file and add the first user account.

Copy to Clipboard

The system will request you to enter the password to the new user account.

Copy to Clipboard

Here is the file content.

Copy to Clipboard

To create additional user accounts, use the following command.

Copy to Clipboard

Edit the Apache configuration file for the default website.

Copy to Clipboard

Insert the following line in the area named: VirtualHost.

Copy to Clipboard

Here is the file content.

Copy to Clipboard

Restart the Apache service.

Copy to Clipboard

Open your browser and enter the IP address of your web server.

In our example, the following URL was entered in the Browser:

• http://172.31.8.195

The Apache server will require you to perform the user authentication.

Nginx authentication

In our example, the configuration will require user authentication to access any part of the website.

In the next example, we will require authentication only to users trying to access a subdirectory named: SECURE.

Copy to Clipboard

Congratulations! You are now able to use the Apache basic authentication.