Skip to content

Apache

mod_loghero is an Apache module. It hooks the point where Apache writes its access log, so it records every request the server answers: HTML pages, images, PDFs, robots.txt, sitemaps, redirects and 404s alike. No application code is involved, and PHP does not have to be in the picture at all.

That completeness is the reason to want it. Nothing else on the origin sees a request for a static file.

Time: an hour or more, most of it the build · Access needed: root on the web server

  • Root on the server, and the ability to restart Apache.
  • A build toolchain on that machine, or an identical one. The module is compiled per Apache build, so a binary from elsewhere will not load.
  • Your Log Hero API key, from the signup flow at log-hero.com.

On a Red Hat family distribution the build dependencies are:

Terminal window
sudo dnf install cmake httpd-devel libcurl-devel openssl-devel
pip install conan

httpd-devel provides apxs, the Apache extension tool that does the actual compiling and installing. Debian and Ubuntu call the same packages apache2-dev, libcurl4-openssl-dev and libssl-dev.

Terminal window
git clone https://github.com/LogHero/lh-mod-loghero.git
cd lh-mod-loghero
conan install sdk/conan/conanfile.txt --build missing \
--profile sdk/conan/profiles/linux.gcc
cmake .
make mod_loghero

The mod_loghero target calls apxs -i -a, which installs the compiled mod_loghero.so into Apache’s module directory and adds the LoadModule line to your configuration. It uses sudo, so expect a password prompt.

Add a configuration file, for example /etc/httpd/conf.d/loghero.conf:

LoadModule loghero_module /usr/lib64/httpd/modules/mod_loghero.so
LogHeroApiKey "YOUR_API_KEY"

The module takes two directives, both at server level:

Directive Arguments What it does
LogHeroApiKey your API key Required. Without it nothing is sent.
LogHeroEnableLogging log level, directory Optional. Writes the module’s own debug log, for example LogHeroEnableLogging debug /var/log/loghero. Only works in a build compiled with logging support.

Then restart Apache:

Terminal window
sudo apachectl configtest && sudo systemctl restart httpd

configtest catches a wrong module path before it takes the site down.

Terminal window
apachectl -M | grep loghero

A line reading loghero_module (shared) means Apache found and loaded it. If nothing comes back, the LoadModule path is wrong or the module was built against a different Apache version.

Open Log Hero → Bot Activity in your Keyword Hero account. Within a few minutes you should see the banner Log Hero is receiving bot traffic for this domain and a non-zero Bot hits figure.

The module buffers in memory and sends a batch after 500 records or 5 minutes, whichever comes first.

One record per request, taken from Apache’s own request structure: the hostname, the requested path, the client IP address, the User-Agent, the Referer, the request method, the status code, the timestamp and how long Apache took to answer.

Because it hooks the log phase, it records requests that never reach an application: static files, redirects Apache handled itself, and 404s for paths that do not exist. Response times are Apache’s, end to end, not just the time PHP spent.

  • Requests answered above it. A CDN or reverse proxy that serves from cache never passes the request to Apache. If you run Cloudflare, CloudFront or Fastly, the edge integration for that CDN sees more.
  • Requests to another server. The module is per server, so a load-balanced site needs it on every node.

The client IP is Apache’s view of the connection. Behind a proxy, that is the proxy unless mod_remoteip is configured to restore the real one.

  • The module does not appear in apachectl -M. It was built against a different Apache, or the LoadModule path does not match where apxs installed it.
  • Apache starts, but nothing arrives. Check the API key is quoted and at server level, then turn on LogHeroEnableLogging and read the module’s own log. Confirm the server may make outbound HTTPS connections.
  • Everything else: No data arriving.