簡體   English   中英

在瀏覽器上運行python CGI腳本,生成腳本代碼(預期輸出)

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

我正在嘗試運行一個小的CGI腳本,但是它在瀏覽器而不是HTML上顯示了腳本代碼。 我正在運行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/

我已將該腳本放在cgi-bin目錄中,並賦予了它可執行的權限(chmod 755),但是它仍然無法正常工作。

我想念的是什么?

問題是您沒有告訴Apache允許您在CGI文件夾中運行CGI腳本。 基本上,您對/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