Page 52 - Open Soource Technologies 304.indd
P. 52

Unit 4: Apache Server Installation in Window



            4.3.3 Tracking Website                                                                Notes

            Often by default, Apache will generate three activity logs: access, agent and referrer. These track
            the accesses to your Website, the browsers being used to access the site and referring urls that
            your site visitors have arrived from.

            It is commonplace now to utilize Apache’s “combined” log format, which compiles all three
            of these logs into one logfile. This is very convenient when using traffic analysis software as a
            majority of these third-party programs are easiest to configure and schedule when only dealing
            with one log file per domain.

            Let’s break down the code in the combined log format and see what it all means.
            LogFormat “%h %l %u %t “%r” %>s %b “%{Referer}i” “%{User-Agent}i”” combined

            LogFormat starts the line and simply tells Apache you are defining a log file type (or nickname),
            in this case, combined. Now let’s look at the cryptic symbols that make up this log file definition.
                %h    Logs the remote host
                %1    Remote logname, if supplied
                %u    Remote user (mostly useful if logging behind authentication)
                %t    The date and time of the request
                %r    The request to your web site
                %s    The status of the request (201, 301, 404, 500, etc.). the > in front of the
                “s”   insures only the last status is logged.
                %b    Bytes sent for request (tracks http bandwidth use)
                %i    Tracks  items  sent  in  the  HTML  header.  So  by  adding  (Referer)  and  (User
                      Agent), we are capturing the referring url and the browser type in the
                      combined log format

            The most common is to identify individual log files for each domain. This is seen in the example
            below, again using the log directive within the <VirtualHost> container for each domain.

                     <VirtualHost 10.0.0.2>
                     DocumentRoot “/home/sites/domain1/html/”

                     ServerName domain1.com
                     ErrorLog /home/sites/domain1/logs/error.log

                     CustomLog /home/sites/domain1/logs/web.log

                     </VirtualHost>
                     <VirtualHost 10.0.0.3>
                     DocumentRoot “/home/sites/domain2/html/”
                     ServerName domain2.com
                     ErrorLog /home/sites/domain2/logs/error.log
                     CustomLog /home/sites/domain2/logs/web.log
                     </VirtualHost>

                     <VirtualHost 10.0.0.4>
                     DocumentRoot “/home/sites/domain3/html/”


                                             LOVELY PROFESSIONAL UNIVERSITY                                    47
   47   48   49   50   51   52   53   54   55   56   57