Apache服务器

编程入门 行业动态 更新时间:2024-10-14 04:29:37
本文介绍了Apache服务器 - 多个目录,不同的错误日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在/ var / WWW两个目录(比如,在/ var / WWW / APP1和/ var / WWW / APP2),它的错误日志我想发送到不同的文件。两者是同一个域下,所以我的认为的,我不能把他们在不同的虚拟主机。因此,例如,我会访问它们为:

的http://本地主机/ APP1

的http://本地主机/ APP2

我碰到这个页面来了

Generate在Apache的

不同的子目录的访问日志

其解完全适用于访问日志。然而,ENV的说法似乎并不与ErrorLog指令工作。

这个发现,我工作的这一点,这似乎是错误之前:

<虚拟主机*:80>  SERVERADMIN射线@本地  的DocumentRoot的/ var / WWW / APP1  <目录/>    选择指数多视图了FollowSymLinks    设置AllowOverride无    为了否认,允许    所有允许  < /目录>  错误日志$ {} APACHE_LOG_DIR /app1/error.log  LOGLEVEL警告  的CustomLog $ {} APACHE_LOG_DIR结合/app1/access.log< /虚拟主机>

我多少有些失落什么我应该做的。也就是说,如果有办法让错误日志的工作或我是否应该跟上配置为每个目录虚拟主机尝试。任何帮助将是AP preciated!谢谢!

解决方案

的 / 为什么你设置目录选项在虚拟主机背景?使用<目录/ var / WWW / APP1> 而不是<目录/>

由于阿帕奇ErrorLog指令文档其背景是服务器配置,虚拟主机 - 这意味着它是唯一可以定义错误日志整个服务器或 VirtalHost ,也不能用于目录。所以,如果你想不同的日志发送到不同的文件尽量使用 SetEnvIf之后来你在哪里都像 SetEnvIf之后REQUEST_URI目录设置环境变量depeding ^ \\ / A1 \\ / A1 和 SetEnvIf之后REQUEST_URI ^ \\ / A2 \\ /!A1 ,然后根据日志写入A1 环境变量。

I have two directories in /var/www (say, /var/www/app1 and /var/www/app2) whose error logs I want sent to different files. Both are under the same domain, so I think that I can't put them under different virtual hosts. So, for example, I would access them as:

localhost/app1

localhost/app2

I came across this page:

Generate access logs for different subdirectories in Apache

whose solution works perfectly for the access logs. However, the "env" argument doesn't seem to work with the ErrorLog directive.

Before this "discovery", I was working on this, which seems wrong:

<VirtualHost *:80> ServerAdmin ray@localhost DocumentRoot /var/www/app1 <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride None Order deny,allow allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/app1/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/app1/access.log combined </VirtualHost>

I'm somewhat lost about what I should be doing. That is, if there is some way to get ErrorLog to work or if I should keep trying with configuring a virtual host for each directory. Any help would be appreciated! Thank you!

解决方案

Why you set Directory options for / in VirtualHost context? Use <Directory /var/www/app1> instead of <Directory />

Due to Apache ErrorLog directive docs its context is server config, virtual host - which means that it's only possible to define ErrorLog for whole server or for VirtalHost, nor for Directory. So if you want to send different logs to different files try to use SetEnvIf to set Env variable depeding on the directory where you are like SetEnvIf Request_URI ^\/a1\/ a1 and SetEnvIf Request_URI ^\/a2\/ !a1 and then write logs depending on a1 environment variable.

更多推荐

Apache服务器

本文发布于:2023-11-01 13:19:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549429.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:服务器   Apache

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!