Apache 2.4拒绝在Linux Mint Tara(例如Ubuntu 18.04)上执行CGI脚本

时间:2020-04-01 22:35:48

标签: linux apache cgi

我有一个几乎是普通的Apache安装程序,它拒绝执行CGI脚本。

要启用CGI功能,我执行了以下操作:

  1. 启用了mod_cgi模块(a2enmod cgi)
  2. 启用了默认CGI配置(a2enconf serve-cgi-bin)
  3. 将/ bin / bash外壳分配给www-data用户
  4. 重新加载服务器

之后,我将这些文件放在/ usr / lib / cgi-bin中:

  • test.py
#!/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')
  • test.c
#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

有人知道这里可能有什么问题吗?

0 个答案:

没有答案
相关问题