How do I see the number of daily visitors to my web site?

Linode Staff

I am running nginx on Ubuntu 16.04 LTS. I have not changed the location of the default web site. I want to see how many daily visitors I have had to my site.

2 Replies

What is a "Visit"?

You may first want to define what you call a visit. For example, if someone browses your site and visits a few pages, does each of those pages count as a visit?

If they visit a page and then 2 hours later they look at another page, is that the same visit?

If two people in the same house look at your page using the same IP Address does that count as one or two visits. If you want to do this, you will need to set up a session cookie and reconfigure your site's log to include this information. We won't discuss how to do this here.

These are some considerations to think about when you are looking at the results.

You will need a program to process the data from your access log.

Each file downloaded from your web server will be logged in your access log. You will want to group these requests together into what you call a "visit". You can write a program to do this, or you can use one already written. We will use an prewritten program called "Vistors"

Here is a website that has the program used in this example

Getting some tools to build the program

To compile it you will need to install the build-essential package on your Linode:

  sudo apt-get install build-essential

Here is a quick run through of the commands you need to download and install the program:

  # Go to your home directory
  cd ~

  # Get the source code
  wget http://www.hping.org/visitors/visitors-0.7.tar.gz

  # Extract the code
  tar -xzvf visitors-0.7.tar.gz

  # Go into the new directory
  cd visitors_0.7/

  # Create the program
  make

Finding your log file

By default the configuration file for nginx on Ubuntu 16.04 LTS is /etc/nginx/nginx.conf

By default this file has the following configuration for your logs:

        access_log /var/log/nginx/access.log;

Generate a report

Once you have compiled the program, you can generate a report from the your access.log file. (If your file is somewhere else, change the command below to reflect its location.):

   ~/visitors_0.7/visitors /var/log/nginx/access.log > report.html

View the report

To view the report, you can use text based Lynx web browser which is not installed by default.

  apt-get install lynx
  lynx ~/visitors_0.7/report.html

I'm personally a fan of GoAccess. It is quick and easy to get started.

It works for a variety of web servers, and you can configure it in all sorts of ways, but it is not necessary to do so.

GoAccess website

The information to get you started is here:

GoAccess Getting Started guide

For your case, Ubuntu 16.04 will be the following steps.

$ sudo apt update
$ sudo apt install goaccess

$ sudo goaccess -f /var/log/nginx/access.log -c

For the final command, if you have left Nginx's logging format the default, you can just select the default option of NCSA Combined Log Format. If you want to find out more, the GoAccess website has lots more options for you to explore.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct