cd /usr/local/directadmin/scripts
./awstats.sh
cd /usr/local/awstats/wwwroot/cgi-bin
nano .htaccess
Options +ExecCGI
AddHandler cgi-script pl
DirectoryIndex awstats.pl
AuthGroupFile /dev/null
AuthName "awstats"
AuthType basic
AuthUserFile /home/USER/domains/DOMAIN/.htpasswd/public_html/awstats/.htpasswd
require valid-user
nano awstats.model.conf
change:
AllowFullYearView=2
with:
AllowFullYearView=3
change:
AllowAccessFromWebToAuthenticatedUsersOnly=0
with:
AllowAccessFromWebToAuthenticatedUsersOnly=1
cp awstats.pl awstats.pl_bak
nano awstats.pl
change:
else {
@PossibleConfigDir = (
"$DIR", "/etc/awstats",
"/usr/local/etc/awstats", "/etc",
"/etc/opt/awstats"
);
}
with:
else {
@PossibleConfigDir = (
"$DIR", "/etc/awstats",
"/usr/local/etc/awstats", "/etc",
"/etc/opt/awstats", "../../awstats/.data"
);
}
$SiteConfig =~ s/^www\.//;
cd /usr/local/directadmin/scripts/custom
chown diradmin.diradmin awstats_process.sh
wget
http://www.pejoo.net/awstats_process.sh
chmod 0700 awstats_process.sh
chown diradmin:diradmin awstats_process.sh
nano awstats_process.sh
change:
if [ ! -e ${DATA_DIR} ]; then
mkdir -p ${DATA_DIR}
chmod 755 ${STATS_DIR}
chmod 711 ${DATA_DIR}
fi
cp -f ${MODEL} ${CONFIG}
chmod 644 ${CONFIG}
perl -pi -e "s#LogFile=\"/var/log/httpd/mylog.log\"#LogFile=\"${LOG}\"#" ${CONFIG}
perl -pi -e "s#SiteDomain=\"\"#SiteDomain=\"${DOMAIN}\"#" ${CONFIG}
perl -pi -e "s#DirData=\".\"#DirData=\"${DATA_DIR}\"#" ${CONFIG}
perl -pi -e "s#DirCgi=\"/cgi-bin\"#DirCgi=\/awstats\"#" ${CONFIG}
perl -pi -e "s#DirIcons=\"/icon\"#DirIcons=\"icon\"#" ${CONFIG}
perl -pi -e "s#ValidHTTPCodes=\"200 304\"#ValidHTTPCodes=\"200 304 206\"#" ${CONFIG}
perl -pi -e "s#DNSLookup=2#DNSLookup=1#" ${CONFIG}
perl -pi -e "s#\#LoadPlugin=\"geoip GEOIP_STANDARD /pathto/GeoIP.dat\"#LoadPlugin=\"geoip GEOIP_STANDARD /var/lib/GeoIP/GeoIP.dat\"#" ${CONFIG}
mkdir -p ${WEBDIR}
cp -Rp ${AWSTATS}/wwwroot/icon ${WEBDIR}
cp -Rp ${AWSTATS}/wwwroot/cgi-bin/lib ${WEBDIR}
cp -Rp ${AWSTATS}/wwwroot/cgi-bin/lang ${WEBDIR}
cp -Rp ${AWSTATS}/wwwroot/cgi-bin/plugins ${WEBDIR}
cp -fp ${AWSTATS}/wwwroot/cgi-bin/awstats.pl ${WEBDIR}
cp -fp ${AWSTATS}/wwwroot/cgi-bin/.htaccess ${WEBDIR}
chown -R ${USER}:${USER} ${WEBDIR}
chown -R root:${ROOTGRP} ${STATS_DIR}
with:
if [ ! -e ${DATA_DIR} ]; then
mkdir -p ${DATA_DIR}
fi
chmod 755 ${STATS_DIR}
chmod 755 ${DATA_DIR}
cp -f ${MODEL} ${CONFIG}
chmod 644 ${CONFIG}
perl -pi -e "s#LogFile=\"/var/log/httpd/mylog.log\"#LogFile=\"${LOG}\"#" ${CONFIG}
perl -pi -e "s#SiteDomain=\"\"#SiteDomain=\"${DOMAIN}\"#" ${CONFIG}
perl -pi -e "s#AllowAccessFromWebToFollowingAuthenticatedUsers=\"\"#AllowAccessFromWebToFollowingAuthenticatedUsers=\"${USER}\"#" ${CONFIG}
perl -pi -e "s#DirData=\".\"#DirData=\"${DATA_DIR}\"#" ${CONFIG}
perl -pi -e "s#DirCgi=\"/cgi-bin\"#DirCgi=\/awstats\"#" ${CONFIG}
perl -pi -e "s#DirIcons=\"/icon\"#DirIcons=\"icon\"#" ${CONFIG}
perl -pi -e "s#ValidHTTPCodes=\"200 304\"#ValidHTTPCodes=\"200 304 206\"#" ${CONFIG}
perl -pi -e "s#DNSLookup=2#DNSLookup=1#" ${CONFIG}
perl -pi -e "s#\#LoadPlugin=\"geoip GEOIP_STANDARD /pathto/GeoIP.dat\"#LoadPlugin=\"geoip GEOIP_STANDARD /var/lib/GeoIP/GeoIP.dat\"#" ${CONFIG}
mkdir -p ${WEBDIR}
cp -Rp ${AWSTATS}/wwwroot/icon ${WEBDIR}
cp -Rp ${AWSTATS}/wwwroot/cgi-bin/lib ${WEBDIR}
cp -Rp ${AWSTATS}/wwwroot/cgi-bin/lang ${WEBDIR}
cp -Rp ${AWSTATS}/wwwroot/cgi-bin/plugins ${WEBDIR}
cp -fp ${AWSTATS}/wwwroot/cgi-bin/awstats.pl ${WEBDIR}
cp -fp ${AWSTATS}/wwwroot/cgi-bin/.htaccess ${WEBDIR}
perl -pi -e "s#AuthUserFile /home/USER/domains/DOMAIN/.htpasswd/public_html/awstats/.htpasswd#AuthUserFile ${UHOME}/domains/${DOMAIN}/.htpasswd/public_html/awstats/.htpasswd#" ${WEBDIR}/.htaccess
mkdir -p ${UHOME}/domains/${DOMAIN}/.htpasswd/public_html/awstats
cat /etc/shadow | grep ${USER} > ${UHOME}/domains/${DOMAIN}/.htpasswd/public_html/awstats/.htpasswd
echo -e "/domains/${DOMAIN}/public_html/awstats" >> ${UHOME}/domains/${DOMAIN}/.htpasswd/.protected.list
chown -R ${USER}:${USER} ${UHOME}/domains/${DOMAIN}/.htpasswd/public_html
chown -R ${USER}:${USER} ${WEBDIR}
chown -R root:${ROOTGRP} ${STATS_DIR}
chmod 755 ${WEBDIR}/awstats.pl
change:
#/usr/bin/perl ${AWSTATS}/tools/awstats_buildstaticpages.pl -config=${DOMAIN} -configdir=${DATA_DIR} -update -diricons=icon -awstatsprog=${AWSTATS}/cgi-bin/awstats.pl -dir=${STATS_DIR} -builddate=%YY%MM
/usr/bin/perl ${AWSTATS}/wwwroot/cgi-bin/awstats.pl -config=${DOMAIN} -configdir=${DATA_DIR} -update -diricons=icon -dir=${STATS_DIR}
RET=$?
#MAIN_FILE=awstats.${DOMAIN}.`date +%y%m`.html
#MAIN_HTML=${STATS_DIR}/${MAIN_FILE}
#INDEX_HTML=${STATS_DIR}/index.html
#if [ -e ${MAIN_HTML} ] && [ ! -e ${INDEX_HTML} ]; then
# ln -sf ${MAIN_FILE} ${INDEX_HTML}
#fi
#changes per month
#ln -sf ${MAIN_FILE} ${INDEX_HTML}
with:
/usr/bin/perl ${AWSTATS}/tools/awstats_buildstaticpages.pl -config=${DOMAIN} -configdir=${DATA_DIR} -update -diricons=icon -awstatsprog=${AWSTATS}/cgi-bin/awstats.pl -dir=${STATS_DIR} -builddate=%YY%MM
/usr/bin/perl ${AWSTATS}/wwwroot/cgi-bin/awstats.pl -config=${DOMAIN} -configdir=${DATA_DIR} -update -diricons=icon -dir=${STATS_DIR}
RET=$?
MAIN_FILE=awstats.${DOMAIN}.`date +%y%m`.html
MAIN_HTML=${STATS_DIR}/${MAIN_FILE}
INDEX_HTML=${STATS_DIR}/index.html
#if [ -e ${MAIN_HTML} ] && [ ! -e ${INDEX_HTML} ]; then
# ln -sf ${MAIN_FILE} ${INDEX_HTML}
#fi
#changes per month
ln -sf ${MAIN_FILE} ${INDEX_HTML}
If awstats already run, you need to delete all awstats.*.*.conf for each domains.
and do this: (do this directly if awstats not run)
echo 'action=tally&value=all' >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq d