Wednesday 15 January 2014

Apache Logging Module mod-log-firstbyte

How to install mod-log-firstbyte:
https://code.google.com/p/mod-log-firstbyte/

1. checkout the same project:

 # Non-members may check out a read-only working copy anonymously over HTTP.
svn checkout http://mod-log-firstbyte.googlecode.com/svn/trunk/ mod-log-firstbyte-read-only
2. readme file:
Compile and install the module using apxs2, e.g.

apxs2 -c mod_log_firstbyte.c
apxs2 -i -a mod_log_firstbyte.la


This will add a line to your configuration file to load the module:

LoadModule log_firstbyte_module /path/to/mod_log_firstbyte.so

The module adds a new option to your log format string: '%F'. This is the request-to-first-byte time, in microseconds. Edit your configuration files to include a new LogFormat directive. I usually use:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D %F" combined-with-firstbyte

###### My custom with epoch time too ######

LogFormat "%{%s}t %D %F %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" " combined-with-firstbyte

%D     The time taken to serve the request, in microseconds.

Sample output:

<epoch> <%D> <%F>   => 1389809102 1471 1080

1389809102 1471 1080 127.0.0.1 - - [15/Jan/2014:18:05:02 +0000] "GET /server-status?auto HTTP/1.1" 200 373 "-" "libwww-perl/6.03"

######## End of My custom log #####

Finally, change the CustomLog directive:

CustomLog /var/log/apache2/access.log combined-with-firstbyte


3. Install the following cheks:

sudo apt-get install apache2-prefork-dev
sudo apt-get install apache2-threaded-dev

4.
sudo apxs2 -c mod_log_firstbyte.c
sudo apxs2 -i -a mod_log_firstbyte.la


5. After updating the config files [2] restart the apache.



Ref Links:

https://code.google.com/p/mod-log-firstbyte/
http://httpd.apache.org/docs/current/mod/mod_log_config.html


6. Installation output:
-----------------------


$ sudo apxs2 -c mod_log_firstbyte.c
/usr/share/apr-1.0/build/libtool --silent --mode=compile --tag=disable-static x86_64-linux-gnu-gcc -prefer-pic -DLINUX=2 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/openssl -I/usr/include/xmltok -pthread     -I/usr/include/apache2  -I/usr/include/apr-1.0   -I/usr/include/apr-1.0   -c -o mod_log_firstbyte.lo mod_log_firstbyte.c && touch mod_log_firstbyte.slo
/usr/share/apr-1.0/build/libtool --silent --mode=link --tag=disable-static x86_64-linux-gnu-gcc -o mod_log_firstbyte.la  -rpath /usr/lib/apache2/modules -module -avoid-version    mod_log_firstbyte.lo


$ sudo apxs2 -i -a mod_log_firstbyte.la
/usr/share/apache2/build/instdso.sh SH_LIBTOOL='/usr/share/apr-1.0/build/libtool' mod_log_firstbyte.la /usr/lib/apache2/modules
/usr/share/apr-1.0/build/libtool --mode=install cp mod_log_firstbyte.la /usr/lib/apache2/modules/
libtool: install: cp .libs/mod_log_firstbyte.so /usr/lib/apache2/modules/mod_log_firstbyte.so
libtool: install: cp .libs/mod_log_firstbyte.lai /usr/lib/apache2/modules/mod_log_firstbyte.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /usr/lib/apache2/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/lib/apache2/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 644 /usr/lib/apache2/modules/mod_log_firstbyte.so
[preparing module `log_firstbyte' in /etc/apache2/mods-available/log_firstbyte.load]
Enabling module log_firstbyte.
To activate the new configuration, you need to run:
  service apache2 restart


How to install other apache modules:

amit@amit:~$ sudo apt-get install libapache2-
Display all 116 possibilities? (y or n)
libapache2-authcassimple-perl      libapache2-mod-php5filter
libapache2-authcookie-perl         libapache2-mod-proxy-html
libapache2-authenntlm-perl         libapache2-mod-python
libapache2-mod-apparmor            libapache2-mod-python-doc
libapache2-mod-apreq2              libapache2-mod-qos
libapache2-mod-auth-cas            libapache2-mod-random
libapache2-mod-auth-kerb           libapache2-mod-removeip
libapache2-mod-auth-memcookie      libapache2-mod-rivet
libapache2-mod-auth-mysql          libapache2-mod-rivet-doc
libapache2-mod-authn-sasl          libapache2-mod-rpaf
libapache2-mod-auth-ntlm-winbind   libapache2-mod-ruby
libapache2-mod-authn-webid         libapache2-mod-ruid2
libapache2-mod-authn-yubikey       libapache2-mod-ruwsgi
libapache2-mod-authnz-external     libapache2-mod-ruwsgi-dbg
libapache2-mod-auth-openid         libapache2-mod-scgi
libapache2-mod-auth-pam            libapache2-modsecurity
libapache2-mod-auth-pgsql          libapache2-mod-shib2
libapache2-mod-auth-plain          libapache2-mod-spamhaus
libapache2-mod-auth-pubtkt         libapache2-mod-speedycgi
libapache2-mod-auth-radius         libapache2-mod-suphp
libapache2-mod-auth-sys-group      libapache2-mod-upload-progress
libapache2-mod-auth-tkt            libapache2-mod-uwsgi
libapache2-mod-authz-unixgroup     libapache2-mod-uwsgi-dbg
libapache2-mod-axis2c              libapache2-mod-vhost-hash-alias
libapache2-mod-bw                  libapache2-mod-vhost-ldap
libapache2-mod-dacs                libapache2-mod-wsgi
libapache2-mod-defensible          libapache2-mod-wsgi-py3
libapache2-mod-dnssd               libapache2-mod-xsendfile
libapache2-mod-encoding            libapache2-reload-perl

https://help.ubuntu.com/13.04/serverguide/httpd.html

No comments:

Post a Comment