but we can use apache's auth_module to add authentication for a specified directory( in this case is awstats).
assume awstats config file is /etc/awstats/awstats.kseeker.com.conf ,
awstats is installed at /usr/local/awstats/, awstats.pl is located at /usr/local/awstats/wwwroot/cgi-bin.
and httpd.conf is located at /etc/httpd/conf/.
step 1: config awstats to enable authentication access
%vi /etc/awstats/awstats.kseeker.com.conf, find the line contains AllowAccessFromWebToAuthenticatedUsersOnly, and the line contains
AllowAccessFromWebToFollowingAuthenticatedUsers, change them as follows:
AllowAccessFromWebToAuthenticatedUsersOnly=1
AllowAccessFromWebToFollowingAuthenticatedUsers="david"
step 2: enable apache authentication for awstats directory
%vi /etc/httpd/conf/httpd.conf, set AllowOverride to All for "/usr/local/awstats/wwwroot/cgi-bin" directory:
<Directory "/usr/local/awstats/wwwroot/cgi-bin">
AllowOverride All
Options None
Order allow,deny
Allow from all
</Directory>
step 3: add authentication file and .htacess file, add user , and restart apache
%cd /usr/local/awstats/wwwroot/cgi-bin
%htpasswd -c userfile david //create user file, it will prompt for user's password.
%cat > .htaccess
AuthUserFile /usr/local/awstats/wwwroot/cgi-bin/userfile
AuthName "Restricted Area For Customers"
AuthType Basic
require valid-user
Ctrl + D
% apachectl restart
No comments:
Post a Comment