Add basic auth to apache2
Written by Administrator    Wednesday, 23 June 2010 10:31    PDF Print E-mail

Here is an extremely short how to allow basic auth to an apache2 web server.

The prerequisites are (in my case):

Ubuntu 9.10                                                                 
Apache2

Step 1: Install appropriate packages.

apt-get install subversion

apt-get install websvn (this will be stored in /usr/share/websvn)

Step 2: Add basic auth to apache2 configuration

Edit vi /etc/apache2/sites-available/default

<Directory /var/www>
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny 
Allow from all
</Directory>

Step 3: Create a directory ouside of apache2 for password file

mkdir /dev/secure                                                          


Step 4: Add a new user (for basic auth)

htpasswd -c /dev/secure/password testuser                  

 

Step 5) Create a test directory in the webserver such as /var/www/test

Step 6) Add a .htaccess file there
Add this content to that file

AuthType Basic
AuthName "Restricted Access"
AuthUserFile /dev/secure/password
Require user testuser

 

Step 7) Add a simple index.html file in the directory
Add content to index.html

<html>hola</html>

Step 8) Restart apache2 /etc/init.d/apache2 restart

That's it

If you browse to localhost/test you shall be promted to enter user testuser and the password you used when creating the password file in step 4

 

Your are currently browsing this site with Internet Explorer 6 (IE6).

Your current web browser must be updated to version 7 of Internet Explorer (IE7) to take advantage of all of template's capabilities.

Why should I upgrade to Internet Explorer 7? Microsoft has redesigned Internet Explorer from the ground up, with better security, new capabilities, and a whole new interface. Many changes resulted from the feedback of millions of users who tested prerelease versions of the new browser. The most compelling reason to upgrade is the improved security. The Internet of today is not the Internet of five years ago. There are dangers that simply didn't exist back in 2001, when Internet Explorer 6 was released to the world. Internet Explorer 7 makes surfing the web fundamentally safer by offering greater protection against viruses, spyware, and other online risks.

Get free downloads for Internet Explorer 7, including recommended updates as they become available. To download Internet Explorer 7 in the language of your choice, please visit the Internet Explorer 7 worldwide page.