简体   繁体   English

apache服务器上的Python cgi

[英]Python cgi on apache server

I am new to python cgi programming. 我是python cgi编程的新手。 I have installed apache 2.2 server on linux mint and I have my html form in var/www folder which is being displayed properly. 我已经在linux mint上安装了apache 2.2服务器,我在var / www文件夹中的html表单正在正确显示。 Action to the form is a cgi script that I've put in the folder /usr/lib/cgi-bin. 对表单的操作是我放在文件夹/ usr / lib / cgi-bin中的cgi脚本。 But on submit, it says "The requested URL /usr/lib/cgi-bin/file.cgi as not found on this server." 但是在提交时,它说“请求的URL /usr/lib/cgi-bin/file.cgi在此服务器上找不到。” Does anyone know the fix for this? 有谁知道修复此问题?

  1. What is the name of your Python program? 你的Python程序的名称是什么? Is it /usr/lib/cgi-bin/file.cgi ? /usr/lib/cgi-bin/file.cgi吗?
  2. What are the rights of this file? 这个文件的权利是什么? Can it be read by apache? 可以通过apache读取吗? Can it be executed? 可以执行吗?
  3. Is first line with #!/usr/bin/env python or similar good? 第一行是#!/usr/bin/env python还是类似的好? Make sure that this file can be run from command line (ie. shebang is good) 确保该文件可以从命令行运行(即shebang是好的)
  4. Does apache receive request with that file? apache是​​否收到该文件的请求? Look at apache logs, especially error.log and access.log (probably in /var/log/apache ) 查看apache日志,尤其是error.logaccess.log (可能在/var/log/apache
  5. Make sure you have enabled ExecCGI for /usr/lib/cgi-bin/ directory in Apache configuration. 确保在Apache配置中为/usr/lib/cgi-bin/目录启用了ExecCGI For examples see at: http://opensuse.swerdna.org/suseapache.html . 有关示例,请访问: http//opensuse.swerdna.org/suseapache.html You can also use ScriptAlias directive. 您也可以使用ScriptAlias指令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM