0

I am trying to set up basic authentication for a linux (centos) server.

I did the following:

mkdir /usr/local/apache
mkdir /usr/local/apache/passwd
echo > /usr/local/apache/passwd/passwords
htpasswd -c /usr/local/apache/passwd/passwords some_user
new password: xxxxxx
confirm password: xxxxxx

Here's the virtual host section:

NameVirtualHost *:80

ServerName localhost 
ServerAlias some.example.site.com
ServerAdmin webmaster@localhost

DocumentRoot /var/www/mysite/web/
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

Alias /winapi /var/www/another_section/
<Directory "/var/www/another_section">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
....

Where do the basic authentication directives go? (to provide basic authentication protection to the entire virtual host):

    AuthType Basic
    AuthName "Restricted Access"
    AuthUserFile /usr/local/apache/passwd/passwords
    Require user some_user      
EastsideDev
  • 333
  • 3
  • 13
  • 1
    . . . Have you read the Apache manual? [there's a whole section on this](http://httpd.apache.org/docs/2.2/howto/auth.html) that tells you where to place the directives (Inside an appropriate `` context, possibly several of them...) – voretaq7 Nov 14 '12 at 19:11
  • what kind of authentication are you trying to do? Simpler would be to use some directory server such as openldap or 389 – chandank Nov 14 '12 at 19:24
  • I am not a sysadmin, but I am required to do this for a client (and the requirement is to use basic authentication). I don't have time to read large sections of the Apache manual, I used all my available hours to get to the state I described in my question. I guess if this is a hardcore server forum, and there is no room for those who may have an occasional question, but don't make a living as sysadmins, then I'll continue researching the issue – EastsideDev Nov 14 '12 at 19:44

1 Answers1

1

The basic authentication goes in your <Directory> block.