Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
每次请求网页时,有没有办法让 Apache 运行命令/程序?我知道我可以每分钟左右扫描一次日志以查找新条目,但是我可以让 Apache 直接调用该命令吗?在其中一个配置文件中可能有这样的选项,但如果有我不知道它是什么。我的服务器运行的是 Ubuntu 9.04。
您可以使用 CustomLog 指令将访问日志通过管道传输到脚本或程序,这在您的情况下可能很有用。您所要做的就是以您选择的语言在 STDIN 上设置一个 while 循环(或类似结构),然后从那里执行您的命令。
http://httpd.apache.org/docs/2.2/logs.html#piped