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
Before you start
Section titled “Before you start”- 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:
sudo dnf install cmake httpd-devel libcurl-devel openssl-develpip install conanhttpd-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.
1. Build the module
Section titled “1. Build the module”git clone https://github.com/LogHero/lh-mod-loghero.gitcd lh-mod-logheroconan install sdk/conan/conanfile.txt --build missing \ --profile sdk/conan/profiles/linux.gcccmake .make mod_logheroThe 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.
2. Configure it
Section titled “2. Configure it”Add a configuration file, for example
/etc/httpd/conf.d/loghero.conf:
LoadModule loghero_module /usr/lib64/httpd/modules/mod_loghero.soLogHeroApiKey "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:
sudo apachectl configtest && sudo systemctl restart httpdconfigtest catches a wrong module path before it takes the site down.
3. Confirm the module is loaded
Section titled “3. Confirm the module is loaded”apachectl -M | grep logheroA 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.
4. Confirm hits are arriving
Section titled “4. Confirm hits are arriving”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.
What the module records
Section titled “What the module records”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.
What the module cannot see
Section titled “What the module cannot see”- 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.
If it doesn’t work
Section titled “If it doesn’t work”- The module does not appear in
apachectl -M. It was built against a different Apache, or theLoadModulepath does not match whereapxsinstalled it. - Apache starts, but nothing arrives. Check the API key is quoted and at
server level, then turn on
LogHeroEnableLoggingand read the module’s own log. Confirm the server may make outbound HTTPS connections. - Everything else: No data arriving.
