How can I run Python CGI scripts on my web server?

可紊 提交于 2019-12-11 07:39:57

问题


I want to run a Python CGI script on my web server (Apache 2.2). When I try to run the test.py file I get the following error:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /test.py
on this server.</p>
</body></html>

In the error log:

[client 127.0.0.1] Options ExecCGI is off in this directory: C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/test.py

So what could be the problem?


回答1:


The error log is telling you that your Web server isn't configured to allow running CGI scripts from that directory.

See How do I enable CGI execution in directories other than the ScriptAlias? in the Apache FAQ.




回答2:


Add Options ExecCGI to a .htaccess file in the folder where the python file is located.

Besides that, don't use CGI but WSGI to execute python apps...




回答3:


Try mod_python.it's an apache module which gets embedded in apache itself and allow users to run python scripts on



来源:https://stackoverflow.com/questions/6611608/how-can-i-run-python-cgi-scripts-on-my-web-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!