{"id":6685,"date":"2020-08-15T10:28:49","date_gmt":"2020-08-15T07:28:49","guid":{"rendered":"https:\/\/kifarunix.com\/?p=6685"},"modified":"2024-03-14T22:36:31","modified_gmt":"2024-03-14T19:36:31","slug":"install-and-setup-awstats-log-analyzer-on-centos-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-setup-awstats-log-analyzer-on-centos-8\/","title":{"rendered":"Install and Setup AWStats Log Analyzer on CentOS 8"},"content":{"rendered":"\n
Welcome to our tutorial on how to install and setup AWStats Log Analyzer on CentOS 8. AWStats<\/a> is an acronym for Below are the features that AWStats Log Reporting tool is able to show upon a full log analysis;<\/p>\n\n\n\n Run system update<\/p>\n\n\n\n We assume that you are installing AWStats on server with a web server setup and running already. For the demo purposes, we will use Apache HTTP server.<\/p>\n\n\n\n Start and enable Web Server to run on system boot.<\/p>\n\n\n\n Open HTTP Server on Firewall;<\/p>\n\n\n\n EPEL repos provide AWStats package on CentOS systems.<\/p>\n\n\n\n However, the AWStats 7.8.1 is current stable release version as of this writing.<\/p>\n\n\n\n To ensure that we install the latest stable release version of AWStats, head over to AWStats at SourceForge.net<\/a> and grab the RPM installer. You can grab the link to the binary and pull it using wget as shown below;<\/p>\n\n\n\n Once the download completes, you can run the installation of AWStats on CentOS 8.<\/p>\n\n\n\n Once the installation is done, proceed to set it up to analyze your web logs. Upon installation, AWStats files are placed in A default configuration file for AWStats is installed as Create a copy of this configuration file and modify it for the analysis of your domain logs.<\/p>\n\n\n\n This creates a copy of the main configuration file with the FQDN of your server;<\/p>\n\n\n\n Next, open your configuration file for editing.<\/p>\n\n\n\n Define the path to the Web server log file to analyze. In this case, we will be using the default Apache access log file.<\/p>\n\n\n\n Enter the log file type you want to analyze. See the possible options on the configuration file. We use the web logs in this setup.<\/p>\n\n\n\n Define the log format. This must match the log format defined on the web server configuration file. For Apache logs;<\/p>\n\n\n\n Define the domain name on which your web server is reached on;<\/p>\n\n\n\n Set all other possible domain names, addresses or virtual host aliases someone can use to access your site.<\/p>\n\n\n\n The configuration is highly commented and you can proceed to make othe configuration changes. For the basic setup, that is just enough.<\/p>\n\n\n\n You can now generate your initial statistics from the current Apache logs on your Web server;<\/p>\n\n\n\n In order to be able to view the statistics generated above on the browser, you need to create an Apache configuration file to define how to process and server the AWStats.<\/p>\n\n\n\n Create AWStats configuration file;<\/p>\n\n\n\n Within the configuration file, you need to define the location of the AWStats CGI\/perf configuration files as the root directory.<\/p>\n\n\n\n Be sure to replace the paths to the AWStats CGI scripts and files accordingly.<\/strong><\/p>\n\n\n\n Save and exit the file once done.<\/p>\n\n\n\n Ensure that the CGI modules are enabled.<\/p>\n\n\n\n Set the ownership of the AWStats path to files to Apache user and group.<\/p>\n\n\n\n Check Apache syntax.<\/p>\n\n\n\n Restart Apache;<\/p>\n\n\n\n Update your statistics;<\/p>\n\n\n\n You can now view your AWStasts on browser via the URL If you created the AWStats config file with the hostname, e.g, And there you go. You can now create a cron job to keep updating your site statistics at a specific interval. For example, to have your site stats updated every 30 mins, install a cron job like as shown below;<\/p>\n\n\n\n Save and install the cron job. You should now have your site stats updated every 30 mins.<\/p>\n\n\n\n AWStats Documentation<\/a><\/p>\n\n\n\n Install GoAccess On Fedora 30\/Fedora 29<\/a><\/p>\n\n\n\n Install GoAccess on Ubuntu 18.04\/Debian 10 Buster<\/a><\/p>\n\n\n\n Install and Setup Adiscon LogAnalyzer on CentOS 8<\/a><\/p>\n\n\n\nAdvanced Web Statistics<\/strong><\/code> and “is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This log analyzer works as a CGI or from command line and shows you all possible information your log contains, in few graphical web pages. It uses a partial information file to be able to process large log files, often and quickly. It can analyze log files from all major server tools like Apache log files (NCSA combined\/XLF\/ELF log format or common\/CLF log format), WebStar, IIS (W3C log format) and a lot of other web, proxy, wap, streaming servers, mail servers and some ftp servers<\/em>“.<\/p>\n\n\n\n
\n
Install AWStats Log Analyzer on CentOS 8<\/h2>\n\n\n\n
dnf update<\/code><\/pre>\n\n\n\n
Install a WebServer on CentOS 8<\/h3>\n\n\n\n
dnf install httpd<\/code><\/pre>\n\n\n\n
systemctl enable --now httpd<\/code><\/pre>\n\n\n\n
firewall-cmd --add-port={80,443}\/tcp --permanent\nfirewall-cmd --reload<\/code><\/pre>\n\n\n\n
Install AWStats on CentOS 8<\/h3>\n\n\n\n
dnf provides awstats<\/code><\/pre>\n\n\n\n
Extra Packages for Enterprise Linux Modular 8 - x86_64 46 kB\/s | 82 kB 00:01 \nawstats-7.7-5.el8.noarch : Advanced Web Statistics\nRepo : epel\nMatched from:\nProvide : awstats = 7.7-5.el8<\/code><\/pre>\n\n\n\n
Download AWStats RPM Package Installer<\/h4>\n\n\n\n
dnf install wget -y<\/code><\/pre>\n\n\n\n
wget https:\/\/tenet.dl.sourceforge.net\/project\/awstats\/AWStats\/7.8\/awstats-7.8-1.noarch.rpm<\/code><\/pre>\n\n\n\n
Install AWStats<\/h4>\n\n\n\n
dnf localinstall awstats-7.8-1.noarch.rpm<\/code><\/pre>\n\n\n\n
Setup AWStats Log Analyzer on CentOS 8<\/h3>\n\n\n\n
\/usr\/local\/awstats<\/strong><\/code> directory.<\/p>\n\n\n\n
\/etc\/awstats\/awstats.model.conf<\/strong><\/code>.<\/p>\n\n\n\n
cp \/etc\/awstats\/awstats{.model,.`hostname`}.conf<\/code><\/pre>\n\n\n\n
ls \/etc\/awstats\/<\/code><\/pre>\n\n\n\n
awstats.centos8.kifarunix-demo.com.conf awstats.model.conf<\/code><\/pre>\n\n\n\n
vim \/etc\/awstats\/awstats.centos8.kifarunix-demo.com.conf<\/code><\/pre>\n\n\n\n
LogFile=\"\/var\/log\/httpd\/centos8.kifarunix-demo.com.access_log\"<\/code><\/pre>\n\n\n\n
LogType=W<\/code><\/pre>\n\n\n\n
LogFormat=1<\/code><\/pre>\n\n\n\n
SiteDomain=\"centos8.kifarunix-demo.com\"<\/code><\/pre>\n\n\n\n
HostAliases=\"localhost 127.0.0.1 REGEX[kifarunix-demo.com$]\"<\/code><\/pre>\n\n\n\n
Generate Web Statistics from Apache Logs<\/h4>\n\n\n\n
\/usr\/local\/awstats\/wwwroot\/cgi-bin\/awstats.pl -config=centos8.kifarunix-demo.com -update<\/code><\/pre>\n\n\n\n
Create\/Update database for config \"\/etc\/awstats\/awstats.centos8.kifarunix-demo.com.conf\" by AWStats version 7.8 (build 20200416)\nFrom data in log file \"\/var\/log\/httpd\/centos8.kifarunix-demo.com.access_log\"...\nPhase 1 : First bypass old records, searching new record...\nSearching new records from beginning of log file...\nPhase 2 : Now process new records (Flush history on disk after 20000 hosts)...\nJumped lines in file: 0\nParsed lines in file: 10000\n Found 0 dropped records,\n Found 0 comments,\n Found 0 blank records,\n Found 2579 corrupted records,\n Found 0 old records,\n Found 7421 new qualified records.<\/code><\/pre>\n\n\n\n
Configure Apache to Display AWStats<\/h4>\n\n\n\n
vim \/etc\/httpd\/conf.d\/kifarunix-demo-awstats.conf<\/code><\/pre>\n\n\n\n
Alias \/awstatsclasses \"\/usr\/local\/awstats\/wwwroot\/classes\/\"\nAlias \/awstatscss \"\/usr\/local\/awstats\/wwwroot\/css\/\"\nAlias \/awstatsicons \"\/usr\/local\/awstats\/wwwroot\/icon\/\"\nScriptAlias \/awstats\/ \"\/usr\/local\/awstats\/wwwroot\/cgi-bin\/\"\n#\n<Directory \"\/usr\/local\/awstats\/wwwroot\">\n Options None\n AllowOverride None\n Require ip 192.168.56.0\/24\n<\/Directory><\/code><\/pre>\n\n\n\n
httpd -M | grep cgi<\/code><\/pre>\n\n\n\n
proxy_fcgi_module (shared)\n proxy_scgi_module (shared)\n cgid_module (shared)<\/code><\/pre>\n\n\n\n
chown -R apache: \/usr\/local\/awstats\/wwwroot\/<\/code><\/pre>\n\n\n\n
httpd -t<\/code><\/pre>\n\n\n\n
Syntax OK<\/code><\/pre>\n\n\n\n
systemctl restart httpd<\/code><\/pre>\n\n\n\n
\/usr\/local\/awstats\/wwwroot\/cgi-bin\/awstats.pl -config=centos8.kifarunix-demo.com -update<\/code><\/pre>\n\n\n\n
View Apache Access Log Statistics on Browser<\/h3>\n\n\n\n
http:\/\/<server-hostname-or-IP>\/awstats\/awstats.pl<\/code>.<\/p>\n\n\n\n
\/etc\/awstats\/awstats.centos8.kifarunix-demo.com.conf<\/strong><\/code>, then you need to use the same hostname on the url as in
http:\/\/centos8.kifarunix-demo.com\/awstats\/awstats.pl<\/strong><\/code>. If you used IP address, then ensure your url is using an IP address. Otherwise, specify the configuration file using
http:\/\/<server-hostname-or-IP>\/awstats\/awstats.pl?config=config-name<\/strong><\/code>, where config-name can be the hostname or IP address specified on the AWStats configuration file.<\/p>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
sudo crontab -e<\/code><\/pre>\n\n\n\n
*\/30 * * * * \/usr\/local\/awstats\/wwwroot\/cgi-bin\/awstats.pl -config=centos8.kifarunix-demo.com -update<\/code><\/pre>\n\n\n\n
Further Reading<\/h3>\n\n\n\n
Related Tutorials<\/h3>\n\n\n\n