Techheadz Tips and Tutorials
Techheadz@Twitter
Enter Search Term
ID: 22 Category: Apache Date Posted: 02/02/2010 Page Impressions : 1,419
0
Print Password protect directory with Apache using .htpasswd

Password protect directory with Apache using .htpasswd

Password protect directory with Apache Password protecting a directory with .htpasswd

To password protect a directory on your webserver, I first edited my apache.conf file, using the following command in the terminal:-
sudo gedit /etc/apache2/apache.conf
Your apache.conf file should now be ready for editing. Place this code at the bottom of your apache.conf file and save it.
<Directory />
Options FollowSymLinks
AllowOverride None
AuthType Basic
AuthName "ENTER ANYTHING YOU LIKE"
AuthUserFile /var/www/.htpasswd
Require valid-user
</Directory>
You now need to make two changes to the code. These are listed below.

Change the AuthName
The AuthName is what is displayed in the password box when it pops up, asking for a username and password

Change the AuthUserFile
Specify the location of the .htpasswd file. In my case it is located in my var/www Save the file again.

TIP:For extra security you could place this somewhere else in your directory.

It’s now time to create the .htpasswd file, which will be saved in var/www

I found a great site for creating your .htpasswd file.

Visit http://www.4webhelp.net/us/password.php

Enter your name and then your password.

Press the encrypt button and it will generate some code for you.

Copy this code into a new text file and save this as .htpasswd

Drop this file in to your var-www directory and restart Apache2

To restart Apache2. Enter the following code in the terminal.
sudo /etc/init.d/apache2 restart
Now access your website. For example http://localhost or 127.0.0.1

If everything goes as planned, a security box should now appear asking for your Username and Password.

Enter the username and password you specified earlier. You should then be able to access the protected directory on your server.

Enter the wrong username and password to make sure it’s working properly.

Your .htpasswd file is now complete and you have learnt how to protect a directory. Other experienced users may know of other ways to do this. I would not know what to do for more than one password protected directory.



 
Search Techheadz
Ubuntu Ubuntu - Install Adobe Reader in Ubuntu 12.04. sudo apt-get install acroread
Ubuntu Ubuntu - Install veetle in Ubuntu
Ubuntu Ubuntu - Install Putty in Ubuntu
Ubuntu Ubuntu - Install gparted in Ubuntu. sudo apt-get install gparted
Ubuntu Ubuntu - Install Sopcast in Ubuntu Unity 12.04
Ubuntu Ubuntu - Ubuntu 12.04. Make Unity Launcher Icons Smaller.
MySQL MySQL - Import - Export MySQL using the terminal in Ubuntu Linux
Ubuntu Ubuntu - Ubuntu swappiness. Improve ubuntu performance. vm.swappiness=10. sysctl.conf
Ubuntu Ubuntu - Convert .ogv file to .mp4, .webm, .avi in Ubuntu using ffmpeg
Kubuntu Kubuntu - Install Adobe Reader in Kubuntu 12.10, Ubuntu 12.10
Ubuntu Ubuntu - Install filezilla in Ubuntu
Ubuntu Ubuntu - Install Google Chrome in Ubuntu 12.04
Apache Apache - How to Start, Stop, Restart an Apache Web Server (Linux Ubuntu)
Ubuntu Ubuntu - Sendmail not found in Ubuntu. Send mail is slow.
Ubuntu Ubuntu - Install Sopcast Player in Ubuntu 12.10
MySQL MySQL - MySQL commands list. MySQL using the terminal.
Ubuntu Ubuntu - VirtualBox Failed to access the USB subsystem. sudo usermod -aG vboxusers {username}
Ubuntu Ubuntu - Could not update ICEauthority file
CSS CSS - Stretch table width and height to 100% of screen using css and html
Ubuntu Ubuntu - How do I install a firewall in Ubuntu 12.10, ufw UncomplicatedFirewall
CSS CSS - How to set table to 100% screen height using CSS and HTML
Ubuntu Ubuntu - Nautilus Image Converter. Batch resize images in Ubuntu.
Perl Perl - Install perl in Ubuntu
Ubuntu Ubuntu - Create a simple bash script in Ubuntu
PHP PHP - session.save_path. Change the PHP session path
Search Techheadz
Delete a database in MySQL
Delete a database in MySQL
Delete a database in MySQL
Adobe Flash Player
mysql export
upgrade software
upgrade perl in Ubuntu
Install Adobe Flash in ubuntu 12.04
Install Adobe Flash in ubuntu 12.04
codecs for ubuntu 13.04
stop mail server in plesk
dreamweaver
linux radio streams
ffmpeg
The following packages have unmet dependencies. sopcast-player : Depends: sp-auth (>= 3.0.1) but it is not installable E: Unable to correct problems, you have held broken packages
dreamweaver
export mysql
settings kde
putty ubuntu
editor C++ in ubuntu

Binary Clock
http://www.binaryti.me/
Home | About | Links | Add Your Link | Most Popular | Last Accessed | Related Links | Twitter | Site Map
Apache | CSS | HTML | Javascript | Linux |MySQL | Perl | PHP | Linux News & Games | Retro Computing | Ubuntu | Mint | Kubuntu | Win