【发布时间】:2019-12-02 17:17:01
【问题描述】:
我正在尝试从 /etc/httpd/sites-available 中的 000-default.conf 调用 shell 脚本。
000-default.conf 文件内容为:
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/html/
CustomLog "| sh /scratch/user/test.sh" custom_user_tracking
</VirtualHost>
我的 /etc/httpd/conf/httpd.conf 添加了以下内容:
ServerName localhost
LogFormat "%t [%h] [%m] [%U] [%B] [%b] [%D] [%q] [%s] [%{Referer}i] [%{User-Agent}i]" custom_user_tracking
IncludeOptional sites-enabled/*.conf
IncludeOptional sites-available/*.conf
我在 /var/www/html/ 中保留了一个虚拟 html 文件 index.html的内容:
<!DOCTYPE html>
<html>
<body>
<h1>Hello World!</h1>
</body>
</html>
当我点击http://localhost:80 时,根本不会调用 shell 脚本。 shell 脚本是可执行的,它只打印“Hello World”。
但是当我从 000-default.conf 文件中调用 apache kafka 二进制文件时,它可以正常工作。
修改 000-default.conf 文件:
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/html/
CustomLog "| [HOME_DIR_KAFKA]/bin/kafka-console-producer.sh --topic access-log --broker- list <Remote_host_ip>:9092" custom_user_tracking
</VirtualHost>
现在,当我点击 http://localhost:80 时,消息会发送到远程 kafka 服务器。
任何人都可以在这里帮助我如何从 apache httpd 调用 shell 脚本?
【问题讨论】: