Enabling access logs with lighttpd

I usually hate analytics, because I don’t like to collect other people’s usage data, but some data are just thrown at the server by clients anyway (like the User-Agent string) and we might as well use that to serve our users better. goaccess, despite it’s name, is not written in go. It is a pure C program, just like I love it.

Enabling access logs with lighttpd

lighttpd is a server that is on-par with nginx and I will be using it to demonstrate goaccess by visualizing its logs.

NOTE: goaccess has predefined support for most of the web servers out there and also support custom log formats, so you can theoretically use any server that is able to log client access.

In /etc/lighttpd/lighttpd.conf, enable access logs by making modifications to look like this,

server.modules {
"mod_accesslog",
...
}

accesslog.filename = "/var/log/lighttpd/access.log"

By default lighttpd logs in a combined log format(a recommended format for access logs), but if you want to be pedantic you can add this line,

accesslog.format = "%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""

Optionally you may want rotate your logsafter this step.

Running goaccess

Invoking goaccess is pretty simply, you just have to do,

$ goaccess --log-format COMBINED --output /tmp/reports.html \
        /var/log/lighttpd/ # path we mentioned in the lighttpd.conf

Open /tmp/reports.html in a browser, and if everything went right, you should see something like this,

![[assets/goaccess-bright.png]]

Well that’s it for now! I’ll write about automating this in the coming week, until then follow this awesome article.