我正在尝试为Apache中的某些文件(在Ubuntu上运行)设置一个自定义操作处理程序。在我看来,对于动作处理程序,我的站点配置设置是正确的,但是现在当我访问它处理的任何文件时,它就变成404了。
如果我删除操作处理程序,文件200就像预期的那样变成文本,所以文件确实存在。
以下是站点配置:
<VirtualHost *:80>
ServerName foo.com
ServerAdmin foo@bar.com
DocumentRoot /home/foo/www
AddHandler application/x-httpd-php .php .php3 .php4 .php5 .html .htm
Action test-script "/usr/lib/cgi-bin/tts.cgi"
AddHandler test-script .tts
</VirtualHost>
<Directory "/home/foo/www">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>下面是我希望在访问任何tts文件时执行的测试脚本:
#!/bin/bash
printf "Content-type: text/html\n\n"
printf "Hello World!\n"发布于 2021-10-03 20:41:46
首先,确保使用以下方法启用CGI模块:
a2enmod cgid并尝试将AddHandler添加到Action之上
AddHandler test-script .tts
Action test-script "/usr/lib/cgi-bin/tts.cgi"如果您想运行CGI脚本,只需使用以下配置:
<Directory "/var/www/html/cgi">
Options +ExecCGI
AddHandler cgi-script .cgi .pl .py .rb
</Directory>https://serverfault.com/questions/1079412
复制相似问题