Hurley's World

  • games
  • genealogy
  • videos
  • contact
Home › Blogs › tracy's blog

Multi-Site Server Logs for Lighttpd on Ubuntu

The sites/tracy.hurleyit.com/files/img_thumbnails is not writeable

tracy — Wed, 03/05/2008 - 11:47

Sometimes, Google Analytics just isn't enough when it comes to keeping and interpreting server stats. After finding a suitable log file analyzer, AWStats, the next step involved separating out the log files on a per domain basis. When the server was first set up, everything was shuttled to one set of access and error log files. While AWStats could technically analyze this log, the suggested set up involves having one set per domain. This article details the process of separating out the log files and making sure that these new files get rotated correctly.

Create Log Directories

While it would be possible to keep all of the files in one directory and to just name them relative to the domain, for this tutorial we will assume that we will create subdirectories based on the domain name. The first step would be to create a directory for each domain.


sudo -u www-data mkdir /var/log/lighttpd/www.example1.com
sudo -u www-data mkdir /var/log/lighttpd/www.example2.com

Update lighttpd.conf

After creating the directories, it's time to update the lighttpd conf file in /etc/lighttpd. We'll want to set the log files by host name. We already had directives setting the server.document-root for these domains so we only added the bolded lines.


$HTTP["host"] =~ "(^|\.)example1.com"$" {
server.document-root = "/var/www/www.example1.com",
server.errorlog = "/var/log/lighttpd/www.example1.com/error.log",
accesslog.filename = "/var/log/lighttpd/www.example1.com/access.log",

}

$HTTP["host"] =~ "(^|\.)example2.com$" {
server.document-root = "/var/www/www.example2.com",
server.errorlog = "/var/log/lighttpd/www.example2.com/error.log",
accesslog.filename = "/var/log/lighttpd/www.example2.com/access.log",

}

After adding these directives, you will need to restart the server.

sudo /etc/init.d/lighttpd restart

Update Logrotate

Finally, we will want logrotate to rotate these new directories. Since our main goal is to integrate the logs with AWStats, it made sense to add a separate entry for each log directory. However, if you don't need call different scripts for the different domains, feel free to create one directive. We just copied the existing logrotate configuration and editted it for each of the domains. Below are examples of what this might look like.


/var/log/lighttpd/*.log {
daily
missingok
copytruncate
rotate 60
compress
notifempty
sharedscripts
postrotate
if [ -f /var/run/lighttpd.pid ]; then \
kill -HUP $( fi;
endscript
}
/var/log/lighttpd/www.example1.com/*.log {
daily
missingok
copytruncate
rotate 60
compress
notifempty
sharedscripts
postrotate
if [ -f /var/run/lighttpd.pid ]; then \
kill -HUP $( fi;
endscript
}
/var/log/lighttpd/www.example2.com/*.log {
daily
missingok
copytruncate
rotate 60
compress
notifempty
sharedscripts
postrotate
if [ -f /var/run/lighttpd.pid ]; then \
kill -HUP $( fi;
endscript
}

To make just one configuration entry, it would look like this:


"/var/log/lighttpd/*.log" "/var/log/lighttpd/www.example1.com/*.log" "/var/log/lighttpd/www.example2.com/*.log" {
daily
missingok
copytruncate
rotate 60
compress
notifempty
sharedscripts
postrotate
if [ -f /var/run/lighttpd.pid ]; then \
kill -HUP $( fi;
endscript
}

Sources

  • Lighttpd rotating log files with logrotate tool
  • Howto: Lighttpd web server setting up virtual hosting

Trackback URL for this post:

http://tracy.hurleyit.com/trackback/1140
  • lighttpd
  • logrotate
  • ubuntu
  • tracy's blog
  • Add new comment

  • @citizenherald If I may, I would suggest putting a note on the category page so people know. I know other people who were confused too. — 15 years 46 weeks ago
  • @citizenherald Believe me, I definitely understand. And thanks for the reply, at least I know if I buy the paper it will be in there. — 15 years 46 weeks ago
  • @citizenherald I know it's the last thing you want to hear, but I'm under a paper deluge as it is. Maybe a sub model for online content? — 15 years 46 weeks ago
  • @citizenherald Any chance you guys could post the police and fire logs again? I really miss them. — 15 years 51 weeks ago
  • @danigrrl That was quite amusing. — 15 years 51 weeks ago
  • ‹‹
  • 14 of 17
  • ››
more

Navigation

  • Recent posts

User login

  • Create new account
  • Request new password
Connect
Sign in using Facebook

Hurley's World Community


Hurley's World on Facebook

  • games
  • genealogy
  • videos
  • contact

© Copyright 2009: Tracy Hurley