{"id":13167,"date":"2021-12-20T13:11:52","date_gmt":"2021-12-20T13:11:52","guid":{"rendered":"https:\/\/linuxways.net\/?p=13167"},"modified":"2021-12-20T13:11:52","modified_gmt":"2021-12-20T13:11:52","slug":"how-to-install-goaccess-web-log-analyzer-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-goaccess-web-log-analyzer-on-ubuntu-20-04\/","title":{"rendered":"How to Install GoAccess Web Log Analyzer on Ubuntu 20.04"},"content":{"rendered":"<p>GoAccess is an open-source Terminal and browser-based web log analyzer with a pretty dashboard. It can read and analyze log files of nearly all web formats including Apache, NGINX, CloudFront, Amazon S3, etc. It displays real-time web server statistics by displaying summaries of different reports in a dashboard. It can also create reports in HTML, CSV, and JSON formats. Using GoAccess, you can determine the number of hits, visitors, bandwidth, and also which pages drive more traffic.<\/p>\n<p>In today\u2019s post, we will cover the installation and configuration of the GoAccess web log analyzer on the Ubuntu 20.04 LTS machine. We will also cover how to run GoAccess to view Apache logs and generate reports.<\/p>\n<h2>Prerequisites<\/h2>\n<p>On your Ubuntu machine, you will require:<\/p>\n<ul>\n<li><a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-apache-web-server-on-linux\/\">Apache<\/a> installed and running<\/li>\n<li>A user\u00a0having sudo privileges<\/li>\n<\/ul>\n<h2>Installing GoAccess on Ubuntu<\/h2>\n<p>You can install GoAccess using any of the following three methods:<\/p>\n<ul>\n<li>Installing GoAccess Using Ubuntu Repository<\/li>\n<li>Installing GoAccess from Official GoAccess Repository<\/li>\n<li>Installing GoAccess from Source Code<\/li>\n<\/ul>\n<h3>Method#1 Installing GoAccess Using Ubuntu Repository<\/h3>\n<p>The easiest way to install GoAccess is by using the package available in the Ubuntu default repository. However, this is not the latest version. Follow the below steps for installing GoAccess on Ubuntu:<\/p>\n<p>1. Run the below command to update your system\u2019s list of sources.<\/p>\n<pre>$ sudo apt update<\/pre>\n<p>2. Then install GoAccess by running the command below:<\/p>\n<pre>$ sudo apt install goaccess<\/pre>\n<p>If you are prompted with the<strong> y\/n<\/strong> option, type the letter <strong>y <\/strong>and hit <strong>Enter<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1012\" height=\"592\" class=\"wp-image-13168\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-400.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-400.png 1012w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-400-300x175.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-400-768x449.png 768w\" sizes=\"auto, (max-width: 1012px) 100vw, 1012px\" \/> This will install GoAccess on your Ubuntu machine.<\/p>\n<p>3. To verify the installation of GoAccess, run the command below:<\/p>\n<pre>$ goaccess --version<\/pre>\n<p>The output below verifies that GoAccess version <strong>1.3<\/strong> has been successfully installed on our machine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"515\" height=\"178\" class=\"wp-image-13169\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-401.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-401.png 515w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-401-300x104.png 300w\" sizes=\"auto, (max-width: 515px) 100vw, 515px\" \/><\/p>\n<h3>Method#2 Installing GoAccess from Official GoAccess Repository<\/h3>\n<p>To install the latest stable release of GoAccess, use the GoAccess official repository. Follow the below steps for installing GoAccess latest stable release on Ubuntu:<\/p>\n<p>1. Run the command below to add the GoAccess official repository to your system&#8217;s list of sources:<\/p>\n<pre><strong><em>$ <\/em><\/strong>echo \"deb [arch=amd64] http:\/\/deb.goaccess.io\/ focal main\" | sudo tee -a \/etc\/apt\/sources.list.d\/goaccess.list<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"875\" height=\"90\" class=\"wp-image-13170\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-402.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-402.png 875w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-402-300x31.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-402-768x79.png 768w\" sizes=\"auto, (max-width: 875px) 100vw, 875px\" \/><\/p>\n<p>This command will add the repository in a separate file named <strong>goaccess.list<\/strong> under the <strong>\/etc\/apt\/sources.list.d\/<\/strong> directory.<\/p>\n<p>2. Download and then add the public key of the GoAccess PPA to the apt&#8217;s keyring.<\/p>\n<pre>$ wget -O - https:\/\/deb.goaccess.io\/gnugpg.key | sudo apt-key --keyring \/etc\/apt\/trusted.gpg.d\/goaccess.gpg add -<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"967\" height=\"334\" class=\"wp-image-13171\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-403.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-403.png 967w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-403-300x104.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-403-768x265.png 768w\" sizes=\"auto, (max-width: 967px) 100vw, 967px\" \/><\/p>\n<p>3. Then update the apt\u2019s list of sources:<\/p>\n<pre>$ sudo apt update<\/pre>\n<p>4. Then run the command below to install GoAccess:<\/p>\n<pre>$ sudo apt install goaccess<\/pre>\n<p>If you are prompted with <strong>the y\/n<\/strong> option, type the letter <strong>y<\/strong>. The apt command will then install GoAccess on your system.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"837\" height=\"419\" class=\"wp-image-13172\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-404.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-404.png 837w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-404-300x150.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-404-768x384.png 768w\" sizes=\"auto, (max-width: 837px) 100vw, 837px\" \/><\/p>\n<p>5. To verify the installation of GoAccess, run the command below:<\/p>\n<pre>$ goaccess --version<\/pre>\n<p>The output below verifies that GoAccess latest stable version <strong>1.5.3<\/strong> has been successfully installed on our machine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"498\" height=\"223\" class=\"wp-image-13173\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-405.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-405.png 498w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-405-300x134.png 300w\" sizes=\"auto, (max-width: 498px) 100vw, 498px\" \/><\/p>\n<h3>Method#3 Installing GoAccess from Source Code<\/h3>\n<p>You can also get the latest version of GoAccess by installing it from the source code. Follow the below steps for installing GoAccess latest stable release on Ubuntu:<\/p>\n<p>1. First, you will need to install some software packages in order to compile GoAccess from the source.<\/p>\n<pre>$ sudo apt install build-essential libncursesw5-dev libtokyocabinet-dev libgeoip-dev<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1017\" height=\"310\" class=\"wp-image-13174\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-406.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-406.png 1017w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-406-300x91.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-406-768x234.png 768w\" sizes=\"auto, (max-width: 1017px) 100vw, 1017px\" \/><\/p>\n<p>2. Download the GoAccess source code package from the GoAccess official website. Visit the GoAccess <a href=\"https:\/\/goaccess.io\/download\">Downloads<\/a> page and download the GoAccess latest stable version.<\/p>\n<pre>$ wget https:\/\/tar.goaccess.io\/goaccess-1.5.3.tar.gz<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1088\" height=\"268\" class=\"wp-image-13175\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-407.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-407.png 1088w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-407-300x74.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-407-1024x252.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-407-768x189.png 768w\" sizes=\"auto, (max-width: 1088px) 100vw, 1088px\" \/><\/p>\n<p>The source code package will be an archive file with a <strong>tar.gz<\/strong> extension.<\/p>\n<p>3. Extract the source code archive file using the command below:<\/p>\n<pre>$ tar -xzvf goaccess-1.5.3.tar.gz<\/pre>\n<p>This command will extract the archive into a directory named <strong>goaccess-1.5.3<\/strong> (goaccess-version).<\/p>\n<p>4. Enter inside the directory using the cd command:<\/p>\n<pre>$ cd goaccess-1.5.3<\/pre>\n<p>Once you are in the directory, run the command below:<\/p>\n<pre>$ .\/configure --enable-utf8 --enable-geoip=legacy<\/pre>\n<p>This command will check for the dependencies required to build the application.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"819\" height=\"595\" class=\"wp-image-13176\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-408.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-408.png 819w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-408-300x218.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-408-768x558.png 768w\" sizes=\"auto, (max-width: 819px) 100vw, 819px\" \/><\/p>\n<p>In the end, you will receive the below similar output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"693\" height=\"426\" class=\"wp-image-13177\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-409.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-409.png 693w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-409-300x184.png 300w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><\/p>\n<p>5. Now run the command below to compile the application:<\/p>\n<pre>$ make<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"822\" height=\"421\" class=\"wp-image-13178\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-410.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-410.png 822w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-410-300x154.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-410-768x393.png 768w\" sizes=\"auto, (max-width: 822px) 100vw, 822px\" \/><\/p>\n<p>6. Now install the application using the command below:<\/p>\n<pre>$ sudo make install<\/pre>\n<p>This command will install GoAccess on your Ubuntu machine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"810\" height=\"551\" class=\"wp-image-13179\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-411.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-411.png 810w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-411-300x204.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-411-768x522.png 768w\" sizes=\"auto, (max-width: 810px) 100vw, 810px\" \/><\/p>\n<p>7. To verify the installation of GoAccess, run the command below:<\/p>\n<pre>$ goaccess --version<\/pre>\n<p>The output below verifies that GoAccess latest stable version <strong>1.5.3<\/strong> has been successfully installed on our machine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"507\" height=\"178\" class=\"wp-image-13180\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-412.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-412.png 507w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-412-300x105.png 300w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><\/p>\n<h2>Configuring GoAccess<\/h2>\n<p>Now we will configure GoAccess using its configuration file <strong>goaccess.conf<\/strong>. You can find the location of the GoAccess configuration file using the command below:<\/p>\n<pre>$ goaccess --dcf<\/pre>\n<p>The output below shows the location of the GoAccess configuration file is <strong>\/usr\/local\/etc\/goaccess\/goaccess.conf<\/strong>. Its location can be different on your system.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"485\" height=\"48\" class=\"wp-image-13181\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-413.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-413.png 485w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-413-300x30.png 300w\" sizes=\"auto, (max-width: 485px) 100vw, 485px\" \/><\/p>\n<p>Edit the GoAccess config file as follows:<\/p>\n<pre>$ sudo nano \/usr\/local\/etc\/goaccess\/goaccess.conf<\/pre>\n<p>As we are going to setup GoAccess for Apache, so we will only enable the options meant for Apache\/NGINX\u2019s. To configure the time format, search for the below option in the <strong>goaccess.conf<\/strong> file and remove the <strong>#<\/strong> character from the start of the line:<\/p>\n<pre>time-format %H:%M:%S<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"527\" height=\"116\" class=\"wp-image-13182\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-414.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-414.png 527w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-414-300x66.png 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/p>\n<p>To configure the date format, search for the below option in the <strong>goaccess.conf<\/strong> file and remove the <strong>#<\/strong> character from the start of the line:<\/p>\n<pre>date-format %d\/%b\/%Y<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"564\" height=\"117\" class=\"wp-image-13183\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-415.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-415.png 564w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-415-300x62.png 300w\" sizes=\"auto, (max-width: 564px) 100vw, 564px\" \/><\/p>\n<p>To configure the log format, search for the below option in the <strong>goaccess.conf<\/strong> file and remove the <strong>#<\/strong> character from the start of the line:<\/p>\n<pre>log-format %h %^[%d:%t %^] \"%r\" %s %b \"%R\" \"%u\"<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"567\" height=\"152\" class=\"wp-image-13184\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-416.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-416.png 567w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-416-300x80.png 300w\" sizes=\"auto, (max-width: 567px) 100vw, 567px\" \/><\/p>\n<p>If you have virtual hosts, then you will need to uncomment the below option instead of the above:<\/p>\n<pre>log-format %v:%^ %h %^[%d:%t %^] \"%r\" %s %b \"%R\" \"%u\"<\/pre>\n<p>Now save and close the GoAccess configuration file.<\/p>\n<h2>Running GoAccess<\/h2>\n<p>Apache writes logs to the \/var\/log\/apache2 directory. To run GoAccess, type <em>sudo goaccess<\/em> followed by the Apache log file directory path as follows:<\/p>\n<pre>$ sudo goaccess \/var\/log\/apache2\/access.log<\/pre>\n<p>After running the above command, you will see the below similar dashboard displaying your web server logs in real-time. The display consists of various sections which you can view by scrolling through the Terminal window.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"901\" height=\"787\" class=\"wp-image-13185\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-417.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-417.png 901w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-417-300x262.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-417-768x671.png 768w\" sizes=\"auto, (max-width: 901px) 100vw, 901px\" \/><\/p>\n<h2>Generating Reports<\/h2>\n<p>GoAccess allows you to generate reports in HTML, CSV, and JSON formats.<\/p>\n<p>To generate the report in HTML format, run the command below:<\/p>\n<pre>$ sudo goaccess \/var\/log\/apache2\/access.log -o stats.html<\/pre>\n<p><strong>Note:<\/strong> To generate JSON or CSV report, replace stats.html with stats.json or stats.csv respectively.<\/p>\n<p>This command will generate <strong>stats.html<\/strong> file in the current Terminal directory. To view the HTML report, run the command below:<\/p>\n<pre>$ xdg-open stats.html<\/pre>\n<p>This will open the HTML report in your web browser.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1424\" height=\"754\" class=\"wp-image-13186\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-418.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-418.png 1424w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-418-300x159.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-418-1024x542.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-418-768x407.png 768w\" sizes=\"auto, (max-width: 1424px) 100vw, 1424px\" \/><\/p>\n<h2>Uninstalling GoAccess<\/h2>\n<p>If for any reason you want to remove GoAccess, use the method described below:<\/p>\n<p>If you have installed GoAccess using either the Ubuntu repository or the GoAccess repository, run this command to uninstall it:<\/p>\n<pre>$ sudo apt remove goaccess<\/pre>\n<p>If you have installed GoAccess from the source code, run the below commands to uninstall it:<\/p>\n<pre>$ cd goaccess-1.5.3<\/pre>\n<pre>$ sudo make uninstall<\/pre>\n<p>In today\u2019s post, we covered the installation and configuration of the GoAccess web log analyzer on the Ubuntu 20.04 LTS machine. We have then covered how to run GoAccess to view Apache web server logs and generate reports. To know more about GoAccess, visit the GoAccess official <a href=\"https:\/\/goaccess.io\/man\">Manual<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>GoAccess is an open-source Terminal and browser-based web log analyzer with a pretty dashboard. It can read and analyze log files of nearly all web formats including Apache,&hellip;<\/p>","protected":false},"author":1,"featured_media":13221,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[790,100],"class_list":["post-13167","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-goaccess-web-log-analyzer","tag-ubuntu-20-04"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/13167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=13167"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/13167\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/13221"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=13167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=13167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=13167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}