First of all create a .htaccess file if doesn’t exists and create a .htpasswd file.
Now Add username and password to the .htpasswd file which you can get from this simple tool.
Add the following text in .htaccess :
AuthName “This folder requires a login”
AuthUserFile /home/simsu/projects/TestPalace/Blog/Password_Protect/.htpasswdAuthGroupFile /dev/null
Replace the red highlighted text above to the location of the .htpasswd file. Now open the folder on the site and you will get a screen like below :