How to protect an Apache Website with a password

L'Antre du Tryphon

schedule
2024-12-29 | 17:24h
update
2024-12-29 | 17:26h
person
www.ctheroux.com
domain
www.ctheroux.com

How to protect an Apache Website with a password

This blog post assumes that Apache is already installed.

You’ll need to install this package in order to protect the website with a password.

sudo apt install apache2-utils

First of all, you’ll need to create a password file. In this example, a user called exampleuser is created into the password file /etc/apache2/.htpasswd. The command to create the file and the user is:

htpasswd -c /etc/apache2/.htpasswd exampleuser

You’ll need to add the following lines into the Directory directive related to the site you want to protect:

AuthType Basic AuthName "Restricted Content" AuthUserFile/etc/apache2/.htpasswd Require valid-user 

Advertisement

Imprint
Responsible for the content:
www.ctheroux.com
Privacy & Terms of Use:
www.ctheroux.com
Mobile website via:
WordPress AMP Plugin
Last AMPHTML update:
05.10.2025 - 01:15:59
Privacy-Data & cookie usage: