Apache:python代码在运行ubuntu14.04的Apache上执行错误

2024-05-05 18:00:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图学习如何使用Apache执行python代码。在阅读了各种教程之后,我配置了conf文件 如下所示,以允许python代码执行。你知道吗

000-default.conf

enter image description here

我的python程序hello.py如下所示:

enter image description here

程序放在/var/www/html/cgi-bin/目录下。设置完所有这些之后,当我转到文件的地址(www.domainname.com/cgi-bin/hello.py)时,我遇到了以下错误。你知道吗

enter image description here

如何解决此错误并运行我的代码?你知道吗


Tags: 文件代码py程序defaulthellobinvar
1条回答
网友
1楼 · 发布于 2024-05-05 18:00:55

在python文件中需要一个处理程序。你知道吗

from mod_python import apache

def handler(req):

    req.content_type = "text/plain"
    req.write("Hello World!")

    return apache.OK

相关问题 更多 >