Меню Рубрики

Установка awstat на centos

How to Install and Configure AWStats on CentOS 7

Table of Contents

Introduction

AWStats is a free (and very useful) web analytics reporting tool which generates advanced web, streaming, FTP, or mail server statistics. AWStats analyzes server log files and produces HTML reports in a nice graphical display.

The AWStats log analyzer works as either a CGI program or from the command line. It presents all the information contained your log files in a few easy-to-read web pages. It supports most web server log file formats including Apache and IIS.

In this tutorial, I will explain how to install and configure AWStats on CentOS 7

Requirements

Install the AWStats package

By default the AWStats package is not available in the CentOS 7 repository. You will need to install the EPEL Yum repository on the server.

You can install and enable the EPEL repository by running the following command:

Next, install the awstats package using Yum. This will also install all other required dependencies.

Configure AWStats for Apache

By default AWStats creates an Apache configuration file /etc/httpd/conf.d/awstats.conf . If you need to access AWStats from the network, then you need to update the Allow from and Require with your server’s IP address.

You can do this by editing the AWStats config file:

Update the following lines as shown below. Substitute your own IP address for the sample address 192.168.1.0:

Restart the Apache service to reload new settings

Create an AWStats configuration file

You need to create a configuration file for each website for which you wish to view statistics. Here, we will create a configuration file for the example.com domain.

First, create a copy of the default AWStats configuration file with your domain name:

Next you will need to make some changes in the config file:

Update the following lines:

Save and close the file. Restart the Apache service to reload the new settings:

After these changes, you need to build your initial statistics, which will be generated from the current logs on your server.

The output will look something like this:

Set up Cron to update the logs

It is a good idea to set up a cron job to regularly update the AWStats database using newly-created log entries. This will save you time, as well as ensure that the stats are updated on a regular basis.

You can do this by editing /etc/crontab file:

источник

4 мин для чтения Как установить и настроить веб-статистику Awstats для WordPress и других сайтов

Главное меню » Linux » Как установить и настроить веб-статистику Awstats для WordPress и других сайтов

Мы администрируем сайты на WordPress, которые уже собирают статистику внутри CMS (система управления контентом) с помощью плагинов. Плагины WordPress, однако, не имеют понятия, что происходит за пределами его собственного мира. Вот где Awstats, Webalizer и подобные статистические инструменты могут помочь. Они предоставляют ценную информацию о поисковых системах, ключевых словах, возможных хакерах и многих других вещах, которые администраторы веб-сайта хотят знать.

Эта статья по установке и настройке Awstats было протестировано на Debian 8 (Jessie) и Debian 10 (Buster), работающих под управлением Apache 2.4. мы случайно запускаем серверы WordPress, но Awstats не имеет значения, если вы используете Drupal, Joomla или другой сервер. Если вы используете сервер Windows, эта статья содержит инструкции для него.

Вы должны комфортно редактировать файлы конфигурации Linux, чтобы добиться успеха с установкой Awstats. Это также означает, что вам нужен корневой доступ к системе (или sudo).

Установка Awstats на Debian

Откройте терминальный доступ к серверу и введите команду установки:

После завершения процедуры установки сделайте копию файла определений Awstats:

(заменить mysite.ru с вашим фактическим доменным именем)

Отредактируйте файл awstats.mysite.ru.conf следующим образом (это значения по умолчанию, которые обычно работают):

Откройте файл конфигурации Apache /etc/apache2/sites-available/mysite.conf (mysite – это ваше имя файла conf) и вставьте в файл следующие строки:

Введите следующие команды для активации изменений в конфигурации Apache:

Вы можете посмотреть, как продвигается установка, указав свой веб-браузер на:

Если отображается веб-страница статистики, вы находитесь на правильном пути. В верхней строке отображается время обновления статистики. Вероятно, он напишет ‘никогда не обновляется”. Все в порядке, вам просто нужно вручную запустить первое обновление.

Вернувшись в терминал, введите следующую команду для инициализации Awstats:

Когда статистические данные были инициализированы, Awstats отображает количество строк, найденных в качестве квалифицированных записей, пустых записей и другой информации.

Повторно проверьте страницу статистики в вашем веб-браузере:

Если на странице отображаются статистические данные и ip-адреса, выполняется базовая установка. Однако вполне вероятно, что вам придется настроить Awstats немного больше, чтобы он автоматически выполнялся в фоновом режиме, и вы можете разрешить доступ только авторизованным людям.

Читайте также:  Установка двух проходных выключателей

Настройка Awstats для автоматического обновления статистики

Во время установки Awstats устанавливает интервал, как часто он автоматически обновляет статистику. Тем не менее, дополнительные настройки необходимы, чтобы заставить его работать.

Если вы видите сообщения об ошибках, сообщающие, что Awstats не имеет разрешения на доступ к файлу журнала apache2, права доступа в системе должны быть изменены. Процесс обновления Awstats выполняется в фоновом режиме как пользователь www-data, которому требуется доступ к файлам журналов Apache.

Отредактируйте файл /etc/logrotate.d/apache2 и изменить строку: create 640 root adm на : create 644 root www-data

Измените права доступа Awstat для файлов журнала, введя команду:

Проблемы с правами доступа может быть сложно решить.

Отображение имен стран вместо IP-адресов в Awstats

Для работы функции разрешения страны (Geoip) в Awstats необходимо установить следующие программные пакеты:

загрузка занимает немного времени, так как загружается большая таблица с именами стран и ip-адресами.

Отредактируйте файл конфигурации Awstats: /etc/awstats/awstats.mysite.ru.conf
убедитесь, что следующая строка не раскомментирована:

Защитите свою статистику паролем

Статистическая информация, собранная Awstats, доступна всему цифровому миру, если вы не препятствуете публичному доступу к ней. Основным, простым способом ограничения доступа является настройка пароля http. Отредактируйте файл конфигурации apache2 /etc/apache2/sites-available/mysite.conf.

Apache должен быть перезапущен:

Если у вас еще нет пароля Linux, который можно использовать для этой цели, команда htpasswd может сделать это за вас. Например:

Пароль “password” желательно установить сложным.

Вот и все для конфигурации Awstats. Сравнение статистических данных, которые получают свои данные из различных источников, таких как файлы журналов веб-сервера и данные посетителей, доступные внутри CMS, оказалось ценным для наших администраторов.

Если вы нашли ошибку, пожалуйста, выделите фрагмент текста и нажмите Ctrl+Enter.

источник

How to Setup AWStats (Apache Log Analyzer) on CentOS, RHEL and Fedora

AWStats is a free and very powerful tool that creating statics by analyzing Apache log files, ftp or mail servers. AWStats log analyzer works on CGI or command line interface and generate graphical statics from log files.

This how to guide will help you to install and configure AWStats Apache Log Analyzer on CentOS, RHEL and Fedora systems. This article has been tested with CentOS 7.2 only.

Step 1 – Setup EPEL Repository

Firstly install EPEL repository on your system using below command.

Step 2 – Install Apache Server

AWStats required Apache web server to be running. If you don’t have Apache install Use below commands else you already have httpd installed skip this step.

Step 3: Install AWStats

After installing web server, Let’s install AWStats package using yum. Its will also install all other required dependencies.

Step 4 – Configure Apache for AWStats

By default AWStats creates an Apache configuration file /etc/httpd/conf.d/awstats.conf. Default configuration is ok to use except allow from access. If you need to access awstats from network, update the allow from ip with your system or network ip from where we need to access it.

Restart Apache service to reload new settings

Step 5 – Create AWStats Configuration File

Its required to create an configuration file for each of your website for which statics need to generate. Copy AWStats example configuration file with new name and make changes as below.

Update below settings in awstats.tecadmin.net.conf file

Now execute following command to update logs files

Step 6 – Schedule Cron to Update Logs

Schedule a cron job to regularly update AWStats database using newly created log entries. Add new cron job in crontab like below. Read examples of cron scheduling

Step 7 – Access AWStats in Browser

Use your server ip address or domain name to access AWStats statics. Change domain name at the end of url as per your settings.

Congratulation’s! you have successfully configured AWStats for you website. Read our next article to Setup vnStat ( Web based Network Monitoring Tool ) and Install Munin Network Monitoring Tool on your Linux system.

источник

nuxref

Linux Solutions

AWStats Setup on CentOS

Introduction

AWStats is a great tool for gathering statistics about your website. It acquires everything it needs to know about your site strictly through your websites log files. AWStats is able to scan through these logs line by line and present them in a fantastic report. This report can really help you make strategic decisions going forward as well as spot any anomalies that might be taking place. The tool is smart enough to only scan newer log entries (from when it last ran) allowing you to run it again and again (as often as you want). Thus, once you set this tool up to run daily (or even hourly), you’ll have detailed statistics about your website you can call upon anytime.

Читайте также:  Установка блокировки еатон на уаз патриот

AWStats collects information such as such as:

  • Who is visiting your site.
  • How many visitors you’re getting daily.
  • Where are they’re coming from (did a site link to you?)
  • Where is the visitor from (geographical location
  • … and on and on

The presentation of these collected statistics can be either via a website (HTML), XML and/or as a PDF file. The PDF is especially useful since it combines all of the multiple HTML pages (as presented) into one great big report with a table of contents and hyperlinks throughout it! The PDF is also really easy to navigate and pass along to others who might also be interested.

Why Use AWStats over Google Analytics?

Google Analytics Inaccuracy

It’s really easy to prevent this chunk of JavaScript from running too, you just have to have installed something like Ad-Blocker Plus, Disconnect and/or uBlock into your Web Browser (such as Firefox or Chrome). These plugins specifically block these tracking techniques and eliminate most (if not all) advertising the website might have too.

It doesn’t mean that online analytic tools (like Google Analytics) are not good; no, not at all! But it’s just important to understand that they can’t (and truly aren’t) reporting everything that’s going on with your website and the traffic generated from it.

Another point worth mentioning is that Google Analytics can not monitor and report statistics on traffic used by third party tools. Therefore you can’t use it to monitor any RESTful API services because the programs accessing it will never call these JavaScript snippets of code.

It’s worth pointing out now that if you use AWStats, you’ll have the full picture! You’ll be able to easily identify any anomalies and detect certain forms of malicious intent! You’ll be able to monitor all of your internal (web based) services you may manage. From the public standpoint, you might be very surprised at how much more traffic your website is getting despite what online analytic tools will tell you!

Let’s Get Started

First you’ll want to install the proper packages. You should hook up to my repository and the EPEL repository as well! The EPEL repository hosts AWStats too, but mine is a newer version. We need the EPEL repository for it’s GeoIP packages since they get updated more often there:

You should be good to go now; the following installs AWStats and a few extra tools to get the best out of it:

AWStat In a Nutshell

The steps below will require that you have set up the environment defined below. Obviously you’ll want to change these environment variables to suite your own needs:

Configuring AWStats: Step 1 of 3

AWStats works from configuration files you create in /etc/awstats/. But it also needs a directory it can work within (we use /var/lib/awstats/). I’ve provided documentation around each line so you know what’s going on:

Optionally Configuring GeoIP Updates

The geolite data fetches us a great set of (meta) data we can reference when looking up IP Addresses (of people who visited our site) and determining what part of the world they came from. This information is fantastic when putting together statistics and web page traffic like AWStats does.

First we want to configure AWStats to use the GEO IP Plugin:

Next we want to set up our GEO IP to update itself with the latest meta data for us automatically (so we don’t have to worry about it):

Apache Users: Step 2a of 3

AWStats depends on the log files to build it’s statistics from, so it’s important we point it to the right directory. Apache logs have been pretty much standardized and AWStats just works with them. If your web page is being hosted through Apache then your log files are most likely being placed in /var/log/httpd. If you’re using NginX (and not Apache), you can skip over this section and to Step 2b of 3 instead.

Make sure AWStats knows it’s dealing with Apache log files (make sure you’ve still got the $WEBSITE variable defined from above):

Now what we want to do is take all of the logs files associated with our website in /var/log/httpd and build one great big (sorted) log file we can get all of our statistics out of:

Nginx Users

NginX logs have a slightly different format then the Apache logs and therefore require a slightly different configuration to work. If your web page is being hosted through NginX then your log files are most likely being placed in /var/log/nginx. If you’re using Apache (and not NginX), then you can skip over this section as long as you’ve already done Step 2a of 3 instead.

Make sure AWStats knows it’s dealing with NginX log files otherwise it won’t be able to interpret them. Also be sure to have your $WEBSITE variable defined:

Now we take all of the logs files associated with our website in /var/log/nginx and build one great big (sorted) log file we can get all of our statistics out of:

Statistic Generation: Step 3 of 3

At this point we have all the info we need

Consider throwing the above into a script file and having it ran in a cron job!

Hosting The Statistics

This option is purely optional; but but here is some simple configurations you can use if you want to access these generated statistics from your browser.

Note: I intentionally keep things simple in this section. AWStats can be configured so that you can update your statistics via it’s very own website (see AllowToUpdateStatsFromBrowser directive in the site configuration). However I don’t recommend this option and therefore do not document it below.

NginX

A simple NginX configuration might look like this:

Don’t forget to reload NginX so it takes on your new configuration (and makes that statistics page visible):

Apache

Don’t forget to reload Apache so it takes on your new configuration (and makes that statistics page visible):

Credit

This blog took me a long time to put together and test! The repository hosting alone accommodates all my blog entries up to this date. I took the open source available to me and rebuilt it to make it an easier solution and decided to share it. If you like what you see and wish to copy and paste this HOWTO, please reference back to this blog post at the very least. It’s really all I ask.

Sources

8 thoughts on “ AWStats Setup on CentOS ”

When I try to add your repo I am getting errors..
warning: /var/tmp/rpm-tmp.1eIw43: Header V4 RSA/SHA1 Signature, key ID efe82e3b: NOKEY
################################# [100%]
Updating / installing…
################################# [100%]
error: /etc/pki/rpm-gpg/RPM-GPG-KEY-nuxref-com: import read failed(2).

It sounds like your installing the wrong rpm for the wrong distribution. Here is a similar case (but with EPEL Repos).

What version/OS are you using?

This was with a VPS
centos 7.3.1611 x64
The machine was brand new, just booted, tried again tonight did the same thing.

You asked how the EPEL repo does, I used this instead of yours:
sudo yum install -y epel-release
But when I did try to add it via the command you listed, it stated it was already added,

I did manage to get everything else working with your repo though thanks to your great instructions.

Feel free to email me if you need additional details.

Sorry.. should have replied here, you can delete the other reply..

I was convinced it was your end, but now I’m convinced it is mine.

I pushed a small update, can you try the new RPM i posted?
rpm -Uhi http://repo.nuxref.com/centos/7/en/x86_64/custom/nuxref-release-1.0.0-4.el7.nuxref.noarch.rpm

You can also do it through yum if you want:
yum install http://repo.nuxref.com/centos/7/en/x86_64/custom/nuxref-release-1.0.0-4.el7.nuxref.noarch.rpm

Also… Thanks for bringing this to my attention! 🙂

I started up another machine..
I installed it via the yum command and it seemed to install OK, but.. I ran:
yum update
and got:
http://repo.nuxref.com/centos/7/en/x86_64/custom/repodata/repomd.xml: [Errno 14] curl#6 – “Could not resolve host: repo.nuxref.com; Name or service not known”

I then waited a few minutes… and it worked!
Thanks a bunch.. 🙂

I was playing with a vps… centos 7.3.1611 x64 was the os.. the machine was brand new, just booted, tried again tonight did the same thing.

Just FYI.. awstats is now updated to version 7.6-1.el7 on EPEL repo

That’s great news honestly! I updated my copy to v7.6 too so that it will include all of my personal patches. But I do like hearing that EPEL is actively maintaining this package. I have contacted the package manager of it directly and will submit my subtle changes that fix a few things for us CentOS/RedHat users. Hopefully they will be accepted upstream and I won’t have to maintain a fork of it anymore! 🙂

Also, I’m glad to hear you got your repository setup working again. Thanks for pointing out my issue! I’m a bit slow responding because I was out of town this past week without internet access.

источник

Добавить комментарий