• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Install GoAccess Nginx Access Log Analyzer on Ubuntu 16.04 PHP 7

By Abhishek Ghosh October 19, 2016 11:18 am Updated on October 19, 2016

Install GoAccess Nginx Access Log Analyzer on Ubuntu 16.04 PHP 7

Advertisement

Previously we talked about configuring GeoIP module for Nginx Access log. This guide can be used on live production server. GoAccess is Easy to Install, Output Available on CLI or As HTML Here is How to Install GoAccess Nginx Access Log Analyzer on Ubuntu 16.04. There are two ways to install GoAccess — we can install from their repository with aptitude package manager or can build from source code with extra completion options. This is their official website. They have live demo :

Vim
1
https://goaccess.io

We will take it granted that your these are your LEMP configuration files (default locations for Ubuntu) :

Vim
1
2
3
4
Nginx log file : /var/log/nginx/access.log
Public root : /usr/share/nginx/html
Nginx sites config file : /etc/nginx/sites-available/default
Others : Does not matter

You need to understand if things differ.

Advertisement

---

 

How to Install GoAccess Nginx Access Log Analyzer on Ubuntu 16.04

 

As like we said above,  we can install from their repository with aptitude package manager or can build from source code with extra completion options. If you just want to test or you are not used with building software from source code, you can install from their repository with aptitude package manager. This way is very easy to uninstall. The disadvantage is that, this way will not give the version with all build options. There are two versions of packages. One not built with --enable-tcb=btree (which needs the command apt install goaccess), to have no on-disk support. For Ubuntu 16.04, we can use the version with built with --enable-tcb=btree (which needs the command apt install goaccess-tcb). We will show the installation of goaccess-tcb.

First add the repository, update :

Vim
1
2
3
echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list
wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add -
apt update

Install needed dependencies for GoAccess :

Vim
1
apt install libnginx-mod-http-perl

It will give many a times prompt to change or keep php.ini, nginx.conf etc files. You will always select the option keep your currently-installed version on production server. These are century old packages for Nginx, PHP 7.x. Any error message is misleading. Actually JSON function loaded differently now. Install another such package :

Vim
1
apt install libtokyocabinet9 libncursesw5-dev libgeoip-dev libtokyocabinet-dev

Finally install GoAccess :

Vim
1
apt install goaccess-tcb

Invoke goaccess by this command :

Vim
1
goaccess -f /var/log/nginx/access.log -a

Install GoAccess Nginx Access Log Analyzer on Ubuntu 16-04 PHP 7

Automatic install is not 100% easy. Otherwise we would not write guide. If you get a blank prompt for setup, simply keep first option, then hit c and fill the first field as %T and hit Enter key. It is useless function at this moment. We need to edit the default config file :

Vim
1
nano /etc/goaccess.conf

Find these lines, they should look active like this (not commented out), edit and save :

/etc/goaccess.conf
Vim
1
2
3
4
...
date-format %d/%b/%Y
...
log-format %h %^[%d:%^] "%r" %s %b "%R" "%u"

 

How to Configure GoAccess HTML GUI Dashboard For Nginx on Ubuntu 16.04, PHP 7

 

If upgraded from Ubuntu 14.04 to Ubuntu 16.04 then root il be at /usr/share/nginx/html. Adjust that part. Now, generate HTML file while being there with this command :

Vim
1
goaccess -f /var/log/nginx/access.log -a > /usr/share/nginx/html/report.html

Check with ls :

Vim
1
ls /usr/share/nginx/html/report.html | grep report

It show the HTML file. Now, open your browser to point towards :

Vim
1
2
3
your-domain.com/report.html
or
your-ip/report.html

You will see the Dashboard. Official documentation is on their website about how to use. As we need to update it continuously, we can use this command to create a goaccess.sh script, invoke to copy-paste these with nano ~/goaccess.sh :

location ~/goaccess.sh
Vim
1
2
3
4
#!/bin/sh
rm /usr/share/nginx/html/report.html
goaccess -f /var/log/nginx/access.log -a > /usr/share/nginx/html/report.html
echo -e "[goaccess.sh ran"

There is no typographical error on the above script. We need to properly CHMOD it :

location ~
Vim
1
chmod +x ~/goaccess.sh

Then test run the script :

location ~
Vim
1
sh ~/goaccess.sh

 

Automation With CRON

 

Now you can set cron, for example, if you want to run the script every 12 hourly, then evoke crontab with crontab -e command and add this at the bottom of the file :

regular usage
Vim
1
55 5,17 * * * sh ~/goaccess.sh > /dev/null 2>&1

If you want to run the script (and update the report) every 10 minutes, evoke crontab with crontab -e command and add this at the bottom of the file :

debugging
Vim
1
*/10 * * * * sh ~/goaccess.sh > /dev/null 2>&1

You can see the “log” of whether ran with this command :

Vim
1
grep goaccess /var/log/syslog

This part is complete. It is not a sane idea to keep an HTML file available publicly on a live website. Also such cron can suck huge RAM. In case you keep it, add this to your /etc/nginx/sites-available/default (or whatever named) file :

Vim
1
2
3
4
5
6
location ~ /(\.|wp-config.php|readme.html|license.txt|report.html)
{
        allow 127.0.0.1;
        allow 27.63.170.224;
        deny all;
}

license.txt, wp-config.php are just added for example in case you have such directive to block access to certain files. My IP is 27.63.170.224. I can access it but others can not see. To make 100% sure, I can check that file from Tor browser (My IP will change).

You should not use crontab for production server when you are not on SSH. Simply delete report.html with :

Vim
1
rm /usr/share/nginx/html/report.html

if exiting from SSH, simply comment out the above used cron with # before the line after opening crontab with crontab -e command. For full managed servers, you can keep the file. Actually there is remote possibility of running exploit and get cron’s access by the script kiddies. We made alternative easy ways (see later part of the guide).

 

Advanced Setup For GoAccess HTML GUI Dashboard (Includes Security)

 

Second part is creating bash alias. Open :

Vim
1
nano ~/.bash_aliases

Copy-Paste :

Vim
1
2
3
alias gostat='goaccess -f /var/log/nginx/access.log -a'
alias gogen='sh ~/goaccess.sh'
alias godel='rm /usr/share/nginx/html/report.html'

Source bash profile :

Vim
1
source ~/.bashrc

Type gostat and hit ENTER key to test. Q is exit.
We kept gogen command for generating new HTML report file. godel command will delete HTML report file. You can run gogen command after login to SSH, check HTML report and run godel before exiting SSH. You can forget that you have GoAccess in the context of security.

Tagged With configuring goaccess conf , nginx log analysis , paperuri:(32e01eefab1bed661bf65bfaacbe0366) , ubuntu 16 04 apache access log syslog config , ubuntu loganalyzer php 7

This Article Has Been Shared 286 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Install GoAccess Nginx Access Log Analyzer on Ubuntu 16.04 PHP 7

  • How to Upload Backup to Dropbox from Cloud Server

    Here is How to Upload Backup to Dropbox from Cloud Server in Case You Want To Keep Your Backup of Files and Database on a Free Cloud Storage.

  • WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud

    Here is a Step by Step Guide on Setting Up WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud with All Commands and the Configuration.

  • Steps To Install Nginx Plus on Ubuntu Server (HP Cloud)

    Here Are the Steps To Install Nginx Plus on Ubuntu Server Running on HP Cloud. Nginx Plus is the Paid Version of Nginx with Extra Features.

  • TLS False Start : Exactly How to Get With Nginx

    TLS False Start on Nginx Appears Black Magic to Many New Server Admins. Here is How to Exactly How to Get it With Nginx in Easy Language.

  • Upgrade Ubuntu Server 14.04 to 16.04 With Live WordPress

    Here Are the Detailed Steps on How To Upgrade Ubuntu Server 14.04 to 16.04 With Live WordPress With Kernel Upgrade, Debug & Fixes For Nginx.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What is Voice User Interface (VUI) January 31, 2023
  • Proxy Server: Design Pattern in Programming January 30, 2023
  • Cyberpunk Aesthetics: What’s in it Special January 27, 2023
  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023
  • What is a Data Mesh? January 25, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Install GoAccess Nginx Access Log Analyzer on Ubuntu 16.04 PHP 7," in The Customize Windows, October 19, 2016, February 1, 2023, https://thecustomizewindows.com/2016/10/install-goaccess-nginx-access-log-analyzer-on-ubuntu-16-04-php-7/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT