如何有单独的Apache2日志文件取决于mod_userdir的用户? [英] How to have separate Apache2 log files depending on the user of mod_userdir?
问题描述
我使用的Apache 2.2 mod_userdir给倍数用户访问Web服务器(他们的测试和其他的东西)。
我想给我的用户访问Apache日志(以便他们可以调试他们的脚本),但日志条目(包括错误日志
和的CustomLog
: error.log中的和的的access.log 的)结合在一起(无论用户目录而言)
有没有办法分开登录到多个文件(取决于用户)。
Apache的版本:2.2.16
的的/ etc / apache2的/启用站点-/ 000-默认的配置文件:
<虚拟主机*:80>
站长的ServerAdmin @本地 的DocumentRoot的/ var / WWW
<目录/>
有FollowSymLinks
设置AllowOverride无
< /目录>
<目录/ var / WWW />
选择指数多视图了FollowSymLinks
设置AllowOverride无
为了允许,拒绝
所有允许
< /目录> ScriptAlias指令/的cgi-bin / / usr / lib目录/ cgi-bin目录/
<目录/ usr / lib目录/ cgi-bin目录>
设置AllowOverride无
选项+ ExecCGI -MultiViews + SymLinksIfOwnerMatch
为了允许,拒绝
所有允许
< /目录> 错误日志$ {} APACHE_LOG_DIR /error.log
LOGLEVEL警告
的CustomLog $ {} APACHE_LOG_DIR结合/access.log 别名/ DOC /的/ usr /共享/ DOC /
<目录的/ usr /共享/ DOC />
选择多视图索引了FollowSymLinks
设置AllowOverride无
为了否认,允许
所有拒绝
从127.0.0.0/255.0.0.0允许:: 1/128
< /目录>
< /虚拟主机>
的 /etc/apache2/mods-enabled/userdir.conf 的配置文件:
< IfModule mod_userdir.c>
的UserDir /家庭/ * /的public_html
禁用的UserDir根 <目录为/ home / * /的public_html>
FileInfo的的AllowOverride AuthConfig限制选项
多视图选项索引IncludesNoExec
IndexOptions FoldersFirst FancyIndexing IGNORECASE
php_admin_value open_basedir的..:在/ usr /共享/ PHP /
< /目录> 错误日志/tmp/apache2-userdir-error.log LOGLEVEL警告 的CustomLog /tmp/apache2-userdir-access.log
< / IfModule>
嗯...我99%肯定,你可以使用正则表达式捕获组的SetEnvIf之后要做到这一点...
我做了类似的东西 - 我分裂了用户登录使用该网站的日志关闭(全部)以下内容:
SetEnvIf之后REQUEST_URI^ /〜* $useraccess = 1 的CustomLog /var/www/logs/access.log结合ENV =!useraccess
的CustomLog /var/www/logs/user-access.log结合ENV = useraccess
您应该能够做到:
SetEnvIf之后REQUEST_URI^ /〜([^ /] +)/.*$用户名= $ 1
的CustomLog /var/www/logs/${username}.log结合
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
这篇关于如何有单独的Apache2日志文件取决于mod_userdir的用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!