Mail-Log
awstats mail server statistics configure centos
Install AWstats.
# install from EPEL
[root@mail ~]# yum --enablerepo=epel -y install awstats
# "awstas.(your hostname).conf" is generated automatically
# cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.mail.worldcm.com.conf
[root@mail ~]# vi /etc/awstats/awstats.mail.worldcm.com.conf
# line 51: change
LogFile="/usr/share/awstats/tools/maillogconvert.pl standard < /var/log/maillog |"
OR
LogFile="/usr/bin/maillogconvert.pl standard < /var/log/maillog |"
# line 63: change
LogType=M
# line 122 comment out and the line below
#LogFormat=1
LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd"
# line 154&169: change
SiteDomain="worldcm.com"
HostAliases="worldcm.com mail.worldcm.com"
OR
HostAliases="REGEX[^.*mail\.worldcm\.com$]"
#Faruq
DirData="/var/lib/awstats"
OR
DirData="/var/www/awstats" # Line 203
DirData="/var/www/awstats/lib"203
# line 832: change like follows
LevelForBrowsersDetection=0
LevelForOSDetection=0
LevelForRefererAnalyze=0
LevelForRobotsDetection=0
LevelForSearchEnginesDetection=0
LevelForKeywordsDetection=0
LevelForFileTypesDetection=0
LevelForWormsDetection=0
# line 950: change like follows
ShowMonthStats=UHB
ShowDaysOfMonthStats=HB
ShowDaysOfWeekStats=HB
ShowHoursStats=HB
ShowDomainsStats=0
ShowHostsStats=HBL
ShowRobotsStats=0
ShowEMailSenders=HBML
ShowEMailReceivers=HBML
ShowSessionsStats=0
ShowPagesStats=0
ShowFileTypesStats=0
ShowOSStats=0
ShowBrowsersStats=0
ShowOriginStats=0
ShowKeyphrasesStats=0
ShowKeywordsStats=0
ShowMiscStats=0
ShowHTTPErrorsStats=0
ShowSMTPErrorsStats=1
[root@mail ~]# vi /etc/httpd/conf.d/awstats.conf
Alias /awstats/icon/ /var/www/awstats/icon/
ScriptAlias /awstats/ /var/www/awstats/
<Directory /var/www/awstats/>
DirectoryIndex awstats.pl
Options ExecCGI
order deny,allow
deny from all
# allow from 127.0.0.1
allow from all
</Directory>
Alias /css/ /var/www/awstats/css/
Alias /js/ /var/www/awstats/js/
# Additional Perl modules
<IfModule mod_env.c>
SetEnv PERL5LIB /var/www/awstats/lib:/var/www/awstats/plugins
</IfModule>
OR
<Directory "/usr/share/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
allow from 127.0.0.1 10.0.0.0/24# IP address you permit to access
</Directory>
[root@mail ~]# /etc/rc.d/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
# update reports manually ( it's updated automatically for hours by Cron )
[root@mail ~]#
# /var/www/awstats/awstats.pl -update -config=mail.worldcm.com -configdir=/etc/awstats
OR
# /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mail.worldcm.com-configdir=/etc/awstats
Create/Update database for config "/etc/awstats/awstats.mail.worldcm.com.conf" by AWStats version 7.0 (build 1.971) From data in log file "/usr/share/awstats/tools/maillogconvert.pl standard < /var/log/maillog |"... Phase 1 : First bypass old records, searching new record... Searching new records from beginning of log file... Jumped lines in file: 0 Parsed lines in file: 4 Found 0 dropped records, Found 0 comments, Found 0 blank records, Found 0 corrupted records, Found 4 old records, Found 0 new qualified records.
[root@mail ~]# vi /etc/httpd/conf.d/awstats.conf
#
Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/share/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/share/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
[3]
Access to 'http://(your server's name or IP address)/awstats/awstats.pl?config=mail.worldcm.com with web browser on clients. Then following screen is shown and it's possible to make sure mail log summary.
http://192.168.80.81/awstats/awstats.pl?config=mail.worldcm.com
LOG refresh:
/usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mail.worldcm.com -configdir=/etc/awstats [centos 6/7]
OR
/var/www/awstats/awstats.pl -update -config=mail.worldcm.com -configdir=/etc/awstats [centos 5]
# crontab –e
0 2 * * * /var/www/awstats/awstats.pl -update -config=mail.worldcm.com -configdir=/etc/awstats
Create crontab script in order to update the log file analysis
#crontab –e
0 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.mysite.com -update > /root/awstatsjob/awstats.log
Schedule Cron to Update Logs
0 * * * * /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mail.worldcm.net -configdir=/etc/awstats
Configure file Below attached
<Directory "/usr/local/awstats/cgi-bin">
Order allow,deny
Allow from all
</Directory>
# This is to force authentication when trying to access /awstats
<Location /awstats>
AuthType Basic
AuthName "AWStats Admin Access Required"
AuthUserFile /etc/httpd/conf.d/awstats.passwd
require valid-user
</Location>
-----------------------------------------
Secure your AWStats application
# vi /etc/httpd/conf.d/awstats.conf
----------------------------------------------------------------
#
<Directory "/usr/share/awstats/wwwroot">
Options None
AllowOverride None
<IfModule mod_authz_core.c>
# Apache 2.4
# Require local
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order allow,deny
# Allow from 127.0.0.1
# Allow from ::1
Allow from all
</IfModule>
</Directory>
### Add this line for Passwd
<directory /usr/share/awstats/wwwroot/> AuthType Basic AuthName "AWStats Admin Access Required" AuthUserFile /usr/share/awstats/wwwroot/awstats-htpasswd require valid-user ExpiresActive On ExpiresDefault M310</directory># Additional Perl modules
<IfModule mod_env.c>
SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins
</IfModule>
-------------------------------------------------------------------
# systemctl restart httpd
# htpasswd -c /usr/share/awstats/wwwroot/awstats-htpasswd abc
htpasswd /usr/share/awstats/wwwroot/awstats-htpasswd admin # [ another user]
---------------------------------------------------------------------------------------
<directory /var/www/awstats/>
AuthType Basic
AuthName "AWStats Admin Access Required"
AuthUserFile /var/www/awstats/awstats-htpasswd
require valid-user
ExpiresActive On
ExpiresDefault M310
</directory>
[root@mail ~]# htpasswd -cm /var/www/awstats/awstats-htpasswd admin
New password:
Re-type new password:
Obviously, you don’t want that your website statistics to be public.
# vi /etc/httpd/conf/httpd.conf
Add the following lines at the bottom of your httpd.conf :
Line: 393
# This is to permit URL access to scripts/files in AWStats directory.<Directory "/usr/share/awstats/wwwroot">Options NoneAllowOverride NoneOrder allow,denyAllow from all</Directory><Directory "/usr/share/awstats/wwwroot/cgi-bin">
AllowOverride NoneOptions ExecCGI -MultiViews +SymLinksIfOwnerMatchOrder allow,denyAllow from allAuthType basicAuthName "NOC Authentication"
AuthUserFile /etc/awstats/.htpasswd<Files awstats.pl>Require valid-user</Files></Directory>
8. Generate username and password for HTPASSWD
# cd /etc/awstats/ # htpasswd –c .htpasswd username New password:Re-type new password:Adding password for user username
And you’re DONE. Now you have AWStats installed & secured.
[root@mail ~]# vi /etc/httpd/conf.d/awstats.conf
Alias /awstats/icon/ /var/www/awstats/icon/
ScriptAlias /awstats/ /var/www/awstats/
<Directory /var/www/awstats/>
DirectoryIndex awstats.pl
Options ExecCGI
order deny,allow
Allow from all
# deny from all
# allow from 127.0.0.1
</Directory>
-----------------OR--------------
# Note that path "/usr/share/awstats/" must reflect your AWStats install path.
#
Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/share/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/share/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# Additional Perl modules
<IfModule mod_env.c>
SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins
</IfModule>
Add this line httpd.conf :
# vi /etc/httpd/conf/httpd.conf
380 # </LimitExcept>
381 #</Directory>
382 <Directory "/usr/local/awstats/cgi-bin">
383 Order allow,deny
384 Allow from all
385 </Directory>
386
387 # This is to force authentication when trying to access /awstats
388
389 <Location /awstats>
390 AuthType Basic
391 AuthName "AWStats Admin Access Required"
392 AuthUserFile /etc/httpd/conf.d/awstats.passwd
393 require valid-user
394 </Location>
395
396
-------------
-----------------------------