Apache on Linux

__For Apache log submission (on Linux)__
- Generate a Public Key
- Authorize your host
- Install the log_send script
- Adjust the logrotate daemon
----
__Generate a RSA key__

Type "ssh-keygen -t rsa", let it save with the defaults, and leave the passphrase blank. If you already have a ~/.ssh/id_rsa.pub, even better.

__Add the Public Key to the server__

Transmit the public key to the server. From your home directory you can usually type "scp .ssh/id_rsa.pub user@other-server:" and on our side we will (or in the recipients home directory type) "cat id_rsa.pub>>.ssh/authorized_keys".

Or just simply make the public key generally available or email it to us

__Install the send_web_log script as a cron job__

Attached is a sample script that works with ~~rotated~~ logfiles. This is so we don't duplicate and possibly conflict with log management. If you're not using logrotate...think about using it. Otherwise, you'll need to mod this script to work with non-compressed files and restart apache before and after.


__Configure Log Rotate__

You may also want to configure the logrotate so your log is turned over often enough to be effective. You can find the config file at ~~/etc/logrotate.d/apache2~~ and you are interested in the access_log section. Mine was set to rotate based on size. I commented that out and specified daily. Below is the relevant section. Notice the \* in front of access_log. This handles vhost logfiles that match the patter ~~hostname-access_log~~ as opposed to just ~~access_log~~.

{code:none}
/var/log/apache2/*access_log {
    compress
    dateext
    maxage 365
    rotate 99
    #size=+4096k
    daily
    notifempty
    missingok
    create 644 root root
    postrotate
     /etc/init.d/apache2 reload
    endscript
}
{code}

__Virtual Hosts__

You can either add a %v to a custom log paramter is your awstats conf file and create an apache custom log or change the first line of your logrotate access setting to:
{code:none}/var/log/apache2/*access_log {code}


__Notes:__

Apache by default uses the "combined" log format. If you are not using this, you need to tell us the format you are using and we can work with it, or just switch to using it. It is defined (for apache2 on newer, sysconfig-ish systems) in ~~/etc/sysconfig/apache2~~ on the line

APACHE_ACCESS_LOG="/var/log/apache2/access_log combined
----

You may also want to tie directly to the logrotated and here is some info on this....this might be the best way to do it in fact, we just haven't tried it yet.

http://awstats.sourceforge.net/docs/awstats_faq.html#ROTATE



Comments