I'm using mod_userdir on Apache 2.2 to give multiples users access to a web server (for their tests and other stuff).
I would like to give my users access to apache logs (so that they can debug their scripts) but log entries (both ErrorLog
and CustomLog
: error.log and access.log) are combined together (whatever "user" directory is concerned).
Is there a way to separate log into multiple files (depending of the user).
Apache version : 2.2.16
"/etc/apache2/sites-enabled/000-default" config file:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
"/etc/apache2/mods-enabled/userdir.conf" config file:
<IfModule mod_userdir.c>
UserDir /home/*/public_html
UserDir disabled root
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit Options
Options MultiViews Indexes IncludesNoExec
IndexOptions FoldersFirst FancyIndexing IgnoreCase
php_admin_value open_basedir "..:/usr/share/php/"
</Directory>
ErrorLog /tmp/apache2-userdir-error.log
LogLevel warn
CustomLog /tmp/apache2-userdir-access.log
</IfModule>
Hmmm... I'm 99% sure that you can use regex capture groups on "SetEnvIf" to do this...
I did something similar -- I split the user logs (all of them) off from the website logs using the following:
SetEnvIf Request_URI "^/~.*$" useraccess=1
CustomLog /var/www/logs/access.log combined env=!useraccess
CustomLog /var/www/logs/user-access.log combined env=useraccess
You should be able to do:
SetEnvIf Request_URI "^/~([^/]+)/.*$" username=$1
CustomLog /var/www/logs/${username}.log combined
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With