Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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      
share|improve this question
1  
. . . Have you read the Apache manual? there's a whole section on this that tells you where to place the directives (Inside an appropriate <Directory> 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 –  EastsideDeveloper Nov 14 '12 at 19:44

1 Answer 1

The basic authentication goes in your <Directory> block.

share|improve this answer
1  
Thanks, can you elaborate on your answer and perhaps add a link succinct link to the appropriate documentation (not required)? –  Felix Frank Aug 5 at 15:20
    
You could also put it in a .htaccess file. –  joeg1ff Aug 5 at 15:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.