How to create Apache htpasswd file in Linux OS?

What is htpasswd?

At times during web development, we will need to prevent the whole world from being able to access a particular website. That’s when Apache htpasswd comes into the picture. htpasswd is usually used together with htaccess.


This tutorial will teach you how to create a htpasswd file using command line.

Creating a htpasswd for the first time


Appending new user to existing htpasswd file


Using htpasswd in htaccess


That’s it you are done!

Install Linux, Apache, MySQL, PHP (LAMP) stack on Debian

LAMP stack is a group of open source softwares used to get web servers up and running. This guide assumes that you already have your Debian installed successfully.


Update your OS before install the LAMP stack

1. Install Apache

Apache is the web server in the lamp stack.

Install apache command

(Optional) Test if apache is alive

Get your IP address first

Then open the following url in your web browser

2. Install MySQL

MySQL is the database management system used in LAMP stack.

Install MySQL command

Finish MySQL installation by running this

This will prompt you for your current MySQL root password, which you will most likely have none, because you have just installed MySQL only. So just leave it blank by pressing enter.

Next a series of yes/no questions will appear. All you have to do is just say Yes to all the options.

3. Install PHP

Install PHP command

Finish up by restarting apache

4. Test if PHP is working on your server

By default apache web root directory is at /var/www/html

Create a file called info.php 

(Optional) If nano is not installed yet

Add the following code to info.php

Then save and exit

Restart Apache and visit the url on your web browser as follows

Then you should see your server’s php information


Feel free to contact me at [email protected] if you have any further questions.