2015-07-12 123 views
0

我试图学习如何使用Apache来执行python代码。通过各种教程,我配置了我的conf文件 ,如下所示,以允许执行python代码。Apache:运行在ubuntu 14.04上的Apache的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

如何解决这个错误,让我的代码运行?

回答

1

你需要一个在你的python文件中的处理程序。

from mod_python import apache 

def handler(req): 

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

    return apache.OK 
+0

它的工作!非常感谢你 :) – Vivek

相关问题