⭐️How to Configure Basic Authentication in the Apache WebServer⭐️


Hello Learner!!!!!!

So In this article, we discussed how we can create authentication in our Apache webserver.

for that first start with what is authentication or website authentication and what is basic authentication and why we need this?

📝Authentication 🔐

Authentication is the security process that allows users to verify their identities in order to gain access to their personal accounts on a website. or Authentication is any process by which you verify that someone is who they claim they are.

📝Basic Authentication 🔐

Basic authentication is a simple authentication scheme built into the HTTP protocol. The client sends HTTP requests with the Authorization header that contains the word Basic word followed by a space and a base64-encoded string username:password. For example, to authorize as demo / p@55w0rd the client would send.

So why we need this?

if you have information on your web site that is sensitive or intended for only a small group of people, the techniques in this article will help you make sure that the people that see those pages are the people that you wanted to see them.

📝Apache Webserver

Apache HTTP Server is a free and open-source web server that delivers web content through the internet. It is commonly referred to as Apache and after development, it quickly became the most popular HTTP client on the web.

For this Configuration I use two ways:

  • Manually.
  • Using Ansible Playbook.

Here are Some Steps to httpd Authentication Showing in the below figure:

Httpd Authentication

Step 1: Install Package

So, start with manually configure basic authentication in your web server go to the terminal, and check httpd package is install or not if they don't install using this below command we can install it.

Installation Command of Httpd
# yum install httpd
check Httpd install or not
# rpm -q httpd

Step 2: Go to this folder :

var/www/html and create one html page

# cd /var/www/html
# vi index.html

Step 3: Configure Httpd and go to the file cd /etc/httpd/conf

and search file named as httpd.conf and then replace none keyword to AuthConfig in this file.

Path of the conf file
Replace in.htaccess file side

Step 4: Create .htaccess file in the document root of the httpd.

In short go to var/www/html and create one file named as .htaccess

starts with .name of the file is hidden files in our system. for check file is available or not use below command:

# ls -a
Create an access file

Now in the file, we can write basic authentication


Now the important step for authentication is to create user name and password.

Step5: Create user name and Password for this we can use below command:

# htpasswd -c /etc/www.passwd username
User Creation
Successful user-created

start the httpd service using the below command:

# systemctl start httpd

Now test basic authentication start or not in our webserver go to browser and check:

Go to the browser and type the IP address and show the sign-in popup in your browser
Successfully login and output come

So now I am using an ansible tool for doing this basic autitentication and create a playbook, using ansible-playbook this manual process is more optimize and fast.

Now performing all the steps and write the script in the playbook, In this Playbook, we have also installed passlib library:

see this

Playbook for Authentication
Playbook for Authentication
Check Connectivity
Successfully run playbook
Successfully run Playbook

I hope you like this article!!!!!!

Thank you!🤝

Keep Learning 🤩





Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A Step by Step Guide to a Lower AWS S3 Bill

Retrospective Gamification: Retrospective from a Hat

Flash Stock Rom on Arise ar40

Flash Android phone

To the Bootcamp and Beyond: My Coding Journey

ReconArt for NetSuite

Build & deploy .Net

1-Click WebServer Provisioning on AWS

Bokeh 1.0 Released

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Simran Shrivas

Simran Shrivas


More from Medium

Welcome to Docker! 🐳

How to create JSON in PowerShell

How to install Chocolatey in windows- DevOps Champ

How To Install WP And Database With Docker-Compose Using Secrets