我有一个几乎是普通的Apache安装程序,它拒绝执行CGI脚本。
要启用CGI功能,我执行了以下操作:
之后,我将这些文件放在/ usr / lib / cgi-bin中:
#!/usr/bin/env python3
with open('/tmp/itexists', 'w') as f: f.write('well, we got that far, at least')
print("Content-Type: text/html\n\n")
print('something')
#include <stdio.h>
int main( void ) {
FILE* f = fopen("/tmp/cpowah", "w"); fwrite("WORKS!!!!\n", 10, 1, f); fclose(f);
printf("Content-Type: text/plain\n\n");
printf("Blah-Blah-Blah");
}
然后将test.c编译成test.exe
然后将所有这些文件分配给www-data用户/组并赋予适当的权限(例如755)
如果我以www-data用户身份手动启动它们,它们将按预期方式工作,但是当我尝试向localhost / test.py或localhost / test.exe发出请求时,我会收到“ 500 Internal服务器错误”消息。
对于每次尝试启动这些脚本之一的尝试,error.log都有这样的记录:End of script output before headers: test.py
实际上,看起来Apache甚至没有尝试启动这些脚本:既没有创建/ tmp / itexists,也没有创建/ tmp / cpowah。我没有使用SELinux,也没有使用mod_suexec。 Apache版本是2.4.29-1ubuntu4.13
有人知道这里可能有什么问题吗?