{"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<p>Welcome to our tutorial on how to install and setup AWStats Log Analyzer on CentOS 8. <a href=\"https:\/\/awstats.sourceforge.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">AWStats<\/a>  is an acronym for <code><strong>Advanced Web Statistics<\/strong><\/code> and &#8220;<em>is a&nbsp;free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This&nbsp;log analyzer&nbsp;works as a&nbsp;CGI or from command line&nbsp;and shows you all possible information your log contains, in&nbsp;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>&#8220;.<\/p>\n\n\n\n<p>Below are the features that AWStats Log Reporting tool is able to show upon a full log analysis;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Number of visits, and number of unique visitors,<\/li>\n\n\n\n<li>Visits duration and last visits,<\/li>\n\n\n\n<li>Authenticated users, and last authenticated visits,<\/li>\n\n\n\n<li>Days of week and rush hours (pages, hits, KB for each hour and day of week),<\/li>\n\n\n\n<li>Domains\/countries of hosts visitors (pages, hits, KB, 269 domains\/countries detected, GeoIp detection),<\/li>\n\n\n\n<li>Hosts list, last visits and unresolved IP addresses list,<\/li>\n\n\n\n<li>Most viewed, entry and exit pages,<\/li>\n\n\n\n<li>Files type,<\/li>\n\n\n\n<li>Web compression statistics (for mod_gzip or mod_deflate),<\/li>\n\n\n\n<li>OS used (pages, hits, KB for each OS, 35 OS detected),<\/li>\n\n\n\n<li>Browsers used (pages, hits, KB for each browser, each version (Web, Wap, Media browsers: 97 browsers, more than 450 if using browsers_phone.pm library file),<\/li>\n\n\n\n<li>Visits of robots (319 robots detected),<\/li>\n\n\n\n<li>Worms attacks (5 worm&#8217;s families),<\/li>\n\n\n\n<li>Search engines, key phrases and keywords used to find your site<\/li>\n\n\n\n<li>HTTP errors<\/li>\n\n\n\n<li>Other personalized reports based on url, url parameters, referer field for miscellaneous\/marketing purpose,<\/li>\n\n\n\n<li>Number of times your site is &#8220;added to favourites bookmarks&#8221;.<\/li>\n\n\n\n<li>Screen size (need to add some HTML tags in index page).<\/li>\n\n\n\n<li>Ratio of Browsers with support of: Java, Flash, RealG2 reader, Quicktime reader, WMA reader, PDF reader (need to add some HTML tags in index page).<\/li>\n\n\n\n<li>Cluster report for load balanced servers ratio<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Install AWStats Log Analyzer on CentOS 8<\/h2>\n\n\n\n<p>Run system update<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install a WebServer on CentOS 8<\/h3>\n\n\n\n<p>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<pre class=\"wp-block-preformatted\"><code>dnf install httpd<\/code><\/pre>\n\n\n\n<p>Start and enable Web Server to run on system boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable --now httpd<\/code><\/pre>\n\n\n\n<p>Open HTTP Server on Firewall;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>firewall-cmd --add-port={80,443}\/tcp --permanent\nfirewall-cmd --reload<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install AWStats on CentOS 8<\/h3>\n\n\n\n<p>EPEL repos provide AWStats package on CentOS systems.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf provides awstats<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>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<p>However, the AWStats 7.8.1 is current stable release version as of this writing.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Download AWStats RPM Package Installer<\/h4>\n\n\n\n<p>To ensure that we install the latest stable release version of AWStats, head over to <a href=\"https:\/\/sourceforge.net\/projects\/awstats\/files\/AWStats\/\" target=\"_blank\" rel=\"noreferrer noopener\">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<pre class=\"wp-block-preformatted\"><code>dnf install wget -y<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/tenet.dl.sourceforge.net\/project\/awstats\/AWStats\/7.8\/awstats-7.8-1.noarch.rpm<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install AWStats<\/h4>\n\n\n\n<p>Once the download completes, you can run the installation of AWStats on CentOS 8.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf localinstall awstats-7.8-1.noarch.rpm<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Setup AWStats Log Analyzer on CentOS 8<\/h3>\n\n\n\n<p>Once the installation is done, proceed to set it up to analyze your web logs. Upon installation, AWStats files are placed in <code><strong>\/usr\/local\/awstats<\/strong><\/code> directory.<\/p>\n\n\n\n<p>A default configuration file for AWStats is installed as <code><strong>\/etc\/awstats\/awstats.model.conf<\/strong><\/code>.<\/p>\n\n\n\n<p>Create a copy of this configuration file and modify it for the analysis of your domain logs.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cp \/etc\/awstats\/awstats{.model,.`hostname`}.conf<\/code><\/pre>\n\n\n\n<p>This creates a copy of the main configuration file with the FQDN of your server;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ls \/etc\/awstats\/<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>awstats.centos8.kifarunix-demo.com.conf awstats.model.conf<\/code><\/pre>\n\n\n\n<p>Next, open your configuration file for editing.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/etc\/awstats\/awstats.centos8.kifarunix-demo.com.conf<\/code><\/pre>\n\n\n\n<p>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<pre class=\"wp-block-preformatted\"><code>LogFile=\"\/var\/log\/httpd\/centos8.kifarunix-demo.com.access_log\"<\/code><\/pre>\n\n\n\n<p>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<pre class=\"wp-block-preformatted\"><code>LogType=W<\/code><\/pre>\n\n\n\n<p>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<pre class=\"wp-block-preformatted\"><code>LogFormat=1<\/code><\/pre>\n\n\n\n<p>Define the domain name on which your web server is reached on;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>SiteDomain=\"centos8.kifarunix-demo.com\"<\/code><\/pre>\n\n\n\n<p>Set all other possible domain names, addresses or virtual host aliases someone can use to access your site.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>HostAliases=\"localhost 127.0.0.1 REGEX[kifarunix-demo.com$]\"<\/code><\/pre>\n\n\n\n<p>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<h4 class=\"wp-block-heading\">Generate Web Statistics from Apache Logs<\/h4>\n\n\n\n<p>You can now generate your initial statistics from the current Apache logs on your Web server;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/usr\/local\/awstats\/wwwroot\/cgi-bin\/awstats.pl -config=centos8.kifarunix-demo.com -update<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>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<h4 class=\"wp-block-heading\">Configure Apache to Display AWStats<\/h4>\n\n\n\n<p>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<p>Create AWStats configuration file;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/etc\/httpd\/conf.d\/kifarunix-demo-awstats.conf<\/code><\/pre>\n\n\n\n<p>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<pre class=\"wp-block-code\"><code>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&lt;Directory \"\/usr\/local\/awstats\/wwwroot\"&gt;\n    Options None\n    AllowOverride None\n    Require ip 192.168.56.0\/24\n&lt;\/Directory&gt;<\/code><\/pre>\n\n\n\n<p><strong>Be sure to replace the paths to the AWStats CGI scripts and files accordingly.<\/strong><\/p>\n\n\n\n<p>Save and exit the file once done.<\/p>\n\n\n\n<p>Ensure that the CGI modules are enabled.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>httpd -M | grep cgi<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code> proxy_fcgi_module (shared)\n proxy_scgi_module (shared)\n cgid_module (shared)<\/code><\/pre>\n\n\n\n<p>Set the ownership of the AWStats path to files to Apache user and group.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chown -R apache: \/usr\/local\/awstats\/wwwroot\/<\/code><\/pre>\n\n\n\n<p>Check Apache syntax.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>httpd -t<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>Syntax OK<\/code><\/pre>\n\n\n\n<p>Restart Apache;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart httpd<\/code><\/pre>\n\n\n\n<p>Update your statistics;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/usr\/local\/awstats\/wwwroot\/cgi-bin\/awstats.pl -config=centos8.kifarunix-demo.com -update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">View Apache Access Log Statistics on Browser<\/h3>\n\n\n\n<p>You can now view your AWStasts on browser via the URL <code>http:\/\/&lt;server-hostname-or-IP&gt;\/awstats\/awstats.pl<\/code>.<\/p>\n\n\n\n<p>If you created the AWStats config file with the hostname, e.g, <code><strong>\/etc\/awstats\/awstats.centos8.kifarunix-demo.com.conf<\/strong><\/code>, then you need to use the same hostname on the url as in <code><strong>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 <code><strong>http:\/\/&lt;server-hostname-or-IP&gt;\/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<div><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats.png\" class=\"td-modal-image\"><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1911\" height=\"902\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats.png\" alt=\"Install and Setup AWStats Log Analyzer on CentOS 8\" class=\"wp-image-6695\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats.png?v=1597475642 1911w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats-768x362.png?v=1597475642 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats-1536x725.png?v=1597475642 1536w\" sizes=\"(max-width: 1911px) 100vw, 1911px\" \/><\/figure><\/a><\/div>\n\n\n\n<div><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats-visits.png\" class=\"td-modal-image\"><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1903\" height=\"865\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats-visits.png\" alt=\"Install and Setup AWStats Log Analyzer on CentOS 8\" class=\"wp-image-6696\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats-visits.png?v=1597475684 1903w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats-visits-768x349.png?v=1597475684 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats-visits-1536x698.png?v=1597475684 1536w\" sizes=\"(max-width: 1903px) 100vw, 1903px\" \/><\/figure><\/a><\/div>\n\n\n\n<div><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats-status-codes.png\" class=\"td-modal-image\"><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1901\" height=\"844\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats-status-codes.png\" alt=\"Install and Setup AWStats Log Analyzer on CentOS 8\" class=\"wp-image-6697\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats-status-codes.png?v=1597475701 1901w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats-status-codes-768x341.png?v=1597475701 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/08\/awstats-status-codes-1536x682.png?v=1597475701 1536w\" sizes=\"(max-width: 1901px) 100vw, 1901px\" \/><\/figure><\/a><\/div>\n\n\n\n<p>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<pre class=\"wp-block-preformatted\"><code>sudo crontab -e<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>*\/30 * * * * \/usr\/local\/awstats\/wwwroot\/cgi-bin\/awstats.pl -config=centos8.kifarunix-demo.com -update<\/code><\/pre>\n\n\n\n<p>Save and install the cron job. You should now have your site stats updated every 30 mins.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Further Reading<\/h3>\n\n\n\n<p><a href=\"https:\/\/awstats.sourceforge.io\/#DOC\" target=\"_blank\" rel=\"noreferrer noopener\">AWStats Documentation<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Related Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-goaccess-on-fedora-30-fedora-29\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install GoAccess On Fedora 30\/Fedora 29<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-goaccess-on-ubuntu-18-04-debian-10-buster\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install GoAccess on Ubuntu 18.04\/Debian 10 Buster<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-and-setup-adiscon-loganalyzer-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install and Setup Adiscon LogAnalyzer on CentOS 8<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/installing-perf-performance-analysis-tool-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Installing Perf Performance Analysis Tool on CentOS 8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to our tutorial on how to install and setup AWStats Log Analyzer on CentOS 8. AWStats is an acronym for Advanced Web Statistics and<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,254,72,253],"tags":[1907,1908,1142,1906,1905,1904],"class_list":["post-6685","post","type-post","status-publish","format-standard","hentry","category-howtos","category-apache","category-monitoring","category-web-servers","tag-apache-log-analyzer","tag-awstats","tag-centos-8","tag-configure-apache-for-awstats","tag-configure-awstats-on-centos-8","tag-install-awstats-on-centos-8","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/6685"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=6685"}],"version-history":[{"count":11,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/6685\/revisions"}],"predecessor-version":[{"id":21484,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/6685\/revisions\/21484"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=6685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=6685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=6685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}