Your .htaccess file is probably the problem. Here is the code I use creating new virtual domains with a /private passwd protected area:

my $HTPASSWD_BIN = '/usr/bin/htpasswd'; # add .htaccess and .htpasswd files print "Writing .htaccess and .htpasswd files.....\n"; my $htpasswd_file = "$WWW_ROOT/$domain/.htpasswd"; my $htaccess = get_htaccess( $domain, $htpasswd_file ); print "$htaccess\n" if $VERBOSE; write_file( "$WWW_ROOT/$domain/public_html/private/.htaccess", $htacce +ss ); print `$HTPASSWD_BIN -b -c $htpasswd_file $domain $password`; print "Done!\n"; sub get_htaccess { my ($domain, $htpasswd ) = @_; return <<CODE; AuthUserFile $htpasswd AuthGroupFile /dev/null AuthName $domain AuthType Basic <Limit GET POST> require valid-user CODE }

The first thing to do is put a .htaccess file in the format shown above into any browsable dir. Don't worry about passwords yet (set AuthUserFile to /dev/null or to an existing file whatever). Now if you browse to that dir you should get prompted for a username/pass. If not check the perms on the .htaccess file - can user apache/nobody read it. If you don't get the prompt the underlying issue is in httpd.conf. Find this:

# # This controls which options the .htaccess files in directories can # override. Can also be "All", or any combination of "Options", "FileI +nfo", # "AuthConfig", and "Limit" # AllowOverride None

Change the 'None' to 'All' to get .htaccess working then RTFM to see if you really want 'All' or would prefer 'Some but not all :-)'

Once you have the prompt the rest is details ie apache needs to be able to find and read the password file. As an aside you can send links that autologin in the form:

http://username:password@somedomain.com/private/

This is the same functionality that has been used to spoof bank domain names used for its original purpose.

cheers

tachyon


In reply to Re: run htpasswd as unix command in the program by tachyon
in thread run htpasswd as unix command in the program by gmishra

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.