+4 votes
231 views
How to install Goaccess to analyze Apache Linux Log

in Linux / Unix by (551k points)
reopened | 231 views

1 Answer

+5 votes
Best answer

1. Update the Linux Operating System
2. Install dependencies on Linux
3. Install Apache web server on Linux
4. Install GoAccess on Linux
5. Use GoAccess on Linux

Apache has positioned itself as one of the best solutions for web server tasks thanks to its functions, scalability and scope that allows administrators to have comprehensive solutions at hand not only when implementing web elements but throughout the management process ..

One of the integral solutions when managing Apache is GoAccess which, through graphics, allows us to control everything that happens with our Apache server.

TechnoWikis will make an analysis on how to install GoAccess and in this way see the scope that this utility gives us within the administrative tasks ..

What is GoAccess?
GoAccess has been developed to be a real-time web log analyzer based on open source which has an interactive viewer that runs on a terminal on UNIX systems through the web browser.

When using GoAccess, we will be with a tool that offers useful comprehensive HTTP statistics when managing the entire web system and where specific details are required about the actions that occur in it.

By default, the results generated with this utility are through the terminal, it is capable of generating a complete HTML report in real time, as well as JSON and CSV reports..

GoAccess features
Among the main features of GoAccess we have:
  • All panels and metrics are programmed to be updated every 200 ms in the terminal output and every second in the HTML output which allows us to guarantee that the results will be generated in real time.
  • GoAccess is compatible with any custom log format string, within its predefined options we have Apache, Nginx, Amazon S3, Elastic Load Balancing, CloudFront and more.
  • Monitoring the response time of the application which allows us to track pages that are slowing down the site and thus take administrative actions.
  • GoAccess has the ability to process records incrementally through the B + tree database on the hard disk.
  • GoAccess is written in the C language, for its execution, only ncurses are needed as a dependency.
  • Minimum configuration required
  • By using GoAccess, it will be possible to determine the number of visits, visitors, bandwidth and metrics for slower execution requests by time or date which allows us full control over critical moments.
  • Metrics per virtual host which displays which virtual host is consuming the majority of web server resources at the moment.
  • Customizable color schemes

Now we will see how to install GoAccess and for this we will use Ubuntu 17 Server.


1. Update the Linux Operating System


The first step to take is to update the operating system packages and for this we will execute the following commands:
 sudo apt-get update -y sudo apt-get upgrade -y 
image

2. Install dependencies on Linux


The GoAccess utility is written in C, which is why it will be necessary to install some dependencies required by GoAccess, for this, we can install them with the following command:
 sudo apt-get -y install libncursesw5-dev gcc make libgeoip-dev libtokyocabinet-dev build-essential -y 
image

3. Install Apache web server on Linux

Step 1

GoAccess is a tool focused on analyzing web server logs, so it is necessary to install Apache in the distribution and for its installation it can be installed with the following command:
 sudo apt-get install apache2 -y 
image
Step 2

In this case we already have Apache installed in the system. Once installed we proceed to start the service and enable it at system startup by executing the following:
 sudo systemctl start apache2 sudo systemctl enable apache2 
image

4. Install GoAccess on Linux


Once we complete the previous steps it is time to install GoAccess which we can perform in two ways.
Step 1

The first alternative, which we will use in this tutorial, is through the official GoAccess resource, for this, first, we will download the latest version of GoAccess using the wget command as follows:
 wget http://tar.goaccess.io/goaccess-1.2.tar.gz 
image
Step 2

We proceed to extract the downloaded file by running:
 sudo tar -xzvf goaccess-1.2.tar.gz 
image
Step 3

Now, we will change the directory to goaccess-1.2 and compile GoAccess by running the following command:
 cd goaccess-1.2 sudo ./configure --enable-utf8 --enable-geoip = legacy 
image
Step 4

Once this process is finished we will see the following: image
Step 5

Now we execute:
 sudo make 
image
Step 6

Finally we install GoAccess by running:
 sudo make install 
image
Step 7

The second alternative to install GoAccess is through a repository, for this it will be necessary to download the GoAccess repository using apt with the following command:
 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 - 
Step 8

Then, we will update the repository using the following command:
 sudo apt-get update -y 
Step 8

Finally, we install GoAccess by running:
 sudo apt-get install goaccess -y 

5. Use GoAccess on Linux

Step 1

The time has come to verify the use of GoAccess and for this, first, we will access the Apache web server using the following syntax:
 http: // IP Address 

image

Step 2

As we see, access to Apache works correctly. After accessing the web server, Apache will be responsible for adding some registry entries in the access_log file by default. It is now possible to analyze the Apache web server log from the terminal by executing the following command:
 sudo goaccess /var/log/apache2/access.log --log-format = COMBINED 
image
Step 3

There we find Apache web server statistics in real time. Now, it is also possible to generate a report in HTML format by executing the following line:
 sudo goaccess /var/log/apache2/access.log --log-format = COMBINED -a -o /var/www/html/report.html 
image
Step 4

Once this report is created, we can access it from our browser by executing the following:
 http: //IP_Address/report.html 
image
Step 5

There we can graphically view the real-time statistics of the Apache web server. As we go down we find more sections: image
Step 6

On the left side side we can click on the menu icon to directly access any of the available categories:

image

Step 7

By clicking on the gear icon, we can access the GoAccess settings:

image

Step 8

There we can change the theme, define the number of panels to be deployed and more, these changes are applied immediately: image

We can see how GoAccess is a simple but complete utility that allows us to have centralized control over everything that happens on the Apache web server.


by (3.5m points)
edited

Related questions

+3 votes
1 answer
+3 votes
1 answer
+5 votes
1 answer
asked Nov 19, 2019 in Linux / Unix by backtothefuture (551k points) | 250 views
+4 votes
1 answer
+3 votes
1 answer
asked Sep 29, 2019 in Linux / Unix by backtothefuture (551k points) | 740 views
Sponsored articles cost $40 per post. You can contact us via Feedback
10,634 questions
10,766 answers
510 comments
3 users