Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache VHOSTS and separate logs

Status
Not open for further replies.

SBNservices

IS-IT--Management
Oct 6, 2004
27
0
0
US
I have been trying to set up Apache to log to individual files for each virtual host. Either I get Apache to run without separate logs, or Apache fails to load. I have tried just about everything, but nothing seems to work.

With the config I have below, I am now able to get vhosts working, just not logging the way I want it. I get get to each website no problem. Problem may be that I was using both Yast to initially set up vhosts, while also reading the docs on Apache's site which confused me more. At the moment, the log file will be created, just no data is inserted. Everything is still going to var/log/apache2/access_log. The machine is OpenSuse 10.2

Here is my config:
apache2/conf.d/vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster@my-domain1.com
DocumentRoot /srv/ ServerName ServerAlias ErrorLog /var/log/apache2/ CustomLog /var/log/apache2/ common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@my-domain2.com
DocumentRoot /srv/ ServerName ServerAlias ErrorLog /var/log/apache2/ CustomLog /var/log/apache2/ common
</VirtualHost>

apache2/vhosts.d/vhosts.conf
<VirtualHost DocumentRoot /srv/ ServerName ServerAdmin <Directory /srv/ AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex index.php
</Directory>
ScriptAlias /cgi-bin/ /srv/ <Directory /srv/ AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost DocumentRoot /srv/ ServerName ServerAdmin admin@my-domain2.com
<Directory /srv/ AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex index.php
</Directory>
ScriptAlias /cgi-bin/ /srv/ <Directory /srv/ AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
 
I'm fairly sure that apache doesn't want to open dozens/hundreds of logs and the ensuing logic to split log traffic for busy servers. Can't guarantee that, but it's a trouble I've seen.

I think the recommendation has been to use something like logwatch or a perl script or other solutions to reprocess the mail access log file as it's being written and parse it into per-domain logs in discrete folders, etc.

I'd go googling for it, I'm sure hosting providers do this all the time.

D.E.R. Management - IT Project Management Consulting
 
Why do you have vhosts defined in two diferent files?

 
Apache can do lots of neat things with the logs, including seperate logs for each virtualhost. I remember fighting with something like this and it has to do with the path and/or default log location. I can't put my hands on the documentation at the moment (I recall having trouble finding it originally as well).

As far as apache is concerned, the default locacation for log file is /logs (note the "s"). So, in each VirtualHost, change your log file paths to be starting from apache's default log location (not the filesystem's).

<VirtualHost *:80>
ServerAdmin webmaster@my-domain1.com
DocumentRoot /srv/ ServerName ServerAlias [!]ErrorLog /logs/www.my-domain1.com-error_log[/!]
[!]CustomLog /logs/ common[/!]
</VirtualHost>
 
Good catch, RythmAce. I didn't even notice that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top