Is there any way to get Apache to run a command/program every time a web page is requested? I know I could scan the logs for new entries every minute or so, but can I get Apache to directly call the command? There might be an option like this in one of the configuration files, but if there is I don't know what it is. My server is running Ubuntu 9.04.
有没有办法让Apache在每次请求网页时运行命令/程序?我知道我可以每隔一分钟扫描日志中的新条目,但是我可以让Apache直接调用命令吗?在其中一个配置文件中可能有这样的选项,但如果有,我不知道它是什么。我的服务器正在运行Ubuntu 9.04。
1 个解决方案
#1
You can use the CustomLog directive to pipe the access log to a script or program, which could be useful in your situation. All you would have to do is set up a while loop (or similar structure) on STDIN in the language of your choice and then execute your command from there.
您可以使用CustomLog指令将访问日志传递给脚本或程序,这在您的情况下非常有用。您所要做的就是在您选择的语言中在STDIN上设置while循环(或类似结构),然后从那里执行命令。
#1
You can use the CustomLog directive to pipe the access log to a script or program, which could be useful in your situation. All you would have to do is set up a while loop (or similar structure) on STDIN in the language of your choice and then execute your command from there.
您可以使用CustomLog指令将访问日志传递给脚本或程序,这在您的情况下非常有用。您所要做的就是在您选择的语言中在STDIN上设置while循环(或类似结构),然后从那里执行命令。