简体   繁体   English

在浏览器上运行python CGI脚本,生成脚本代码(预期输出)

[英]Running python CGI script on browser generating script code not expected output

I am trying to run a small CGI script but it is showing script code on browser not the HTML. 我正在尝试运行一个小的CGI脚本,但是它在浏览器而不是HTML上显示了脚本代码。 I am running Apache server and it's configured as per the requirement. 我正在运行Apache服务器,并且已根据要求进行了配置。

DocumentRoot "/home/user/htdocs"
<Directory "/home/user/htdocs">

   Options Indexes FollowSymLinks
   Options +ExecCGI
   AddHandler cgi-script .cgi .py
   Order allow,deny
   Allow from all
   AllowOverride None
   Require all granted
</Directory>

ScriptAlias /cgi-bin/ /home/user/cgi-bin/

I have put the script in cgi-bin directory and given it executable permission( chmod 755) but it still not working. 我已将该脚本放在cgi-bin目录中,并赋予了它可执行的权限(chmod 755),但是它仍然无法正常工作。

What is it which i am missing ? 我想念的是什么?

The problem is that you have not told Apache that your are allowed to run CGI scripts in your CGI folder. 问题是您没有告诉Apache允许您在CGI文件夹中运行CGI脚本。 Basically what your settings for the /home/user/cgi-bin folder, Debian have this as default in their installation (I changed the path though): 基本上,您对/home/user/cgi-bin文件夹的设置是什么,Debian在安装时将其作为默认设置(尽管我更改了路径):

<Directory "/home/user/cgi-bin">
  AllowOverride None
  Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  Order allow,deny
  Allow from all
</Directory>

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

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