Python Hello World程序错误脚本不可执行

2024-09-28 22:35:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试运行一个简单的Python Hello World脚本。我有通过命令行工作的程序,但不是当我试图从我们的网站上运行它。我得到一个404NotFound错误脚本请求无效。脚本不可执行。我正在一个同样运行PHP的Apache web服务器下使用ibmas400 ISeries。你知道吗

我补充道

Options +FollowSymLinks +ExecCGI
AddHandler cgi-script .py

到httpd.conf文件文件来为我的服务器打开Python。我正在运行的文件具有读取和执行权限。 我将在下面发布我当前的配置文件,下面是我试图运行的代码。你知道吗

#!/QOpenSys/usr/bin/python3
print("Content-type: text/html\n");
print("\n\n");
print("<HTML>");
print("<HEAD>");
print("<TITLE>Test</TITLE>");
print("</HEAD>");
print("<BODY>");
print("<H2>Hi there.</h2>");
print("</BODY>");
print("</HTML>");

我仍在试图弄清楚这整条Python的事情,任何帮助都将不胜感激。你知道吗

谢谢你。你知道吗

配置:

# BMAServer Web Server Configuration created by MCCI/Chuck Mason on 2/13/2019
#LoadModule ibm_ssl_module /QSYS.LIB/QHTTPSVR.LIB/QZSRVSSL.SRVPGM

LoadModule zend_enabler_module /QSYS.LIB/QHTTPSVR.LIB/QZFAST.SRVPGM

Listen *:85

DocumentRoot /www/bmaserver/htdocs
TraceEnable Off

Options +Indexes +FollowSymLinks +ExecCGI

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{Cookie}n \"%r\" %t" cookie
LogFormat "%{User-agent}i" agent
LogFormat "%{Referer}i -> %U" referer
LogFormat "%h %l %u %t \"%r\" %>s %b" common

CustomLog logs/access_log combined
LogMaint logs/access_log 3 0
LogMaint logs/error_log 3 0

ServerName BMAserver

SetEnvIf "User-Agent" "Mozilla/2" nokeepalive
SetEnvIf "User-Agent" "JDK/1\.0" force-response-1.0
SetEnvIf "User-Agent" "Java/1\.0" force-response-1.0
SetEnvIf "User-Agent" "RealPlayer 4\.0" force-response-1.0
SetEnvIf "User-Agent" "MSIE 4\.0b2;" nokeepalive
SetEnvIf "User-Agent" "MSIE 4\.0b2;" force-response-1.0

DirectoryIndex menu.php

CgiConvMode %%MIXED/MIXED%%
#TimeOut 30000
KeepAlive Off
HotBackup Off

DefaultFsCCSID 37
CGIJobCCSID 37

AccessFileName .htaccess
AddCharset UTF-8 .htm .html

# zend fastcgi
# Directive name "FastCgiConfig" is not recognized. (argh)
AddType application/x-httpd-php .php
AddHandler fastcgi-script .php

RewriteEngine on

<Location *>
  <LimitExcept GET HEAD OPTIONS TRACE POST>
     Order Allow,Deny
     Deny From All
  </LimitExcept>
</Location>

<Location />
  Require valid-user
  AuthType Basic
  AuthName MHBAServer
  PasswdFile %%SYSTEM%%
  UserID %%CLIENT%%
</Location>

<Directory />
  Order Deny,Allow
  Deny From all
</Directory>

# Allow requests for files in document root
<Directory /www/bmaserver/htdocs>
  Options +FollowSymLinks +ExecCGI
  AddHandler cgi-script .py
  Order Allow,Deny
  Allow From all
  AllowOverride all
</Directory>

# Allow requests for OutQueue
<Directory /www/bmaserver/OutQueue>
  Order Allow,Deny
  Allow From all
</Directory>

AliasMatch ^/htdocs/(.*) /www/bmaserver/htdocs/$1
AliasMatch ^/OutQueue/(.*) /www/bmaserver/OutQueue/$1

Tags: responselibwwwdirectoryagentphpprintallow