Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im trying to setup a server with apache where each user has a logs folder in his home folder and all error/access logs are store in that folder.

My current setup:

<VirtualHost *:80>
  DocumentRoot /home/user/public_html

  ErrorLog /home/user/logs/error.log
  CustomLog /home/user/logs/access.log combined
  LogLevel info


<VirtualHost *:80>
 DocumentRoot /home/user1/public_html

 ErrorLog /home/user1/logs/error.log
 CustomLog /home/user1/logs/access.log combined
 LogLevel info


The problem with this setup is that if i access the site of user1


all logs are stored into /home/user/logs/ instead of /home/user1/logs/. How can i fix this so that the logs will be stored in the right place?

share|improve this question
up vote 2 down vote accepted

CustomLog for apache 2.2 is a per server or per virtual-host setting and the http://localhost/~user1/ and http://localhost/~user2/ type URI scheme are all aliases within the same default virtual-host.

Something like the following works for the CustomLog (ErrorLog doesn't seem to support the env modifier)

<VirtualHost *:80>
  DocumentRoot /var/www/html
  ErrorLog logs/error_log

  SetEnvIf Request_URI ^~user1 user1
  SetEnvIf Request_URI ^~user2 user2

  CustomLog /home/user1/logs/access.log combined env=user1
  CustomLog /home/user2/logs/access.log combined env=user2

share|improve this answer
i didnt set ServerName because i dont have a domain only ip – blejzz May 19 '12 at 12:00
ok, I see a possibility. let me make a test – Tom H May 19 '12 at 12:08

You need to consider that, with a non-trivial amount of users, giving each his own logs will place extra resource requirements on apache.

There is a simple limit on the number of log files it can handle - the system's file descriptor limit.

Additionally, you cannot split the error log within a single vhost.

share|improve this answer
this is just for testing and research purposes – blejzz May 19 '12 at 12:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.