调用python脚本的php脚本在ssh终端中有效,但浏览器窗口中没有输出

时间:2019-06-17 06:28:54

标签: php python-3.x server

以下使用php -f phptest.php执行的代码片段给出了输出(服务器是运行Centos7的GCP虚拟实例):

[[1、2、3],[4、5、6],[7、8、9]]
string(34)“ [[1、2、3],[4、5、6],[7、8、9]]”

在终端窗口中。另一方面,使用服务器IP和适当的URL运行时,相同的代码给出:

string(0)“”

这是两个脚本:

#!/usr/bin/env python  
def foo():    
    x=str([[1,2,3],[4,5,6],[7,8,9]])  
    return x  
x=foo()  
print(x)  

<?php
$command = "python_location pyfile.py"
escapeshellcmd($commmand);
$output = shell_exec($command);
$strout=print_r($output,true);
echo($strout);
var_dump($strout);
?>

服务器没有目录/var/log/apache2/error.log。相反,我能够找到包含以下内容的/ var / log / httpd / error_log:

[Sun Jun 16 05:04:34.269345 2019] [auth_digest:notice] [pid 21434] AH01757:生成摘要身份验证的机密... [Sun Jun 16 05:04:34.284400 2019] [lbmethod_heartbeat:notice] [pid 21434] AH02282:mod_heartmonitor中没有slotmem [Sun Jun 16 05:04:34.284500 2019] [mpm_prefork:notice] [pid 21434] AH00163:配置了Apache / 2.4.6(CentOS)PHP / 7.3.6-恢复正常运行 [Sun Jun 16 05:04:34.284505 2019] [core:notice] [pid 21434] AH00094:命令行:'/ usr / sbin / httpd -D FOREGROUND' [Sun Jun 16 05:11:53.245377 2019] [autoindex:error] [pid 32206] [客户端187.10.191.110:35833] AH01276:无法提供目录/ var / www / html /:没有匹配的DirectoryIndex(index.html,index (.php),并由Options指令禁止服务器生成的目录索引 [Sun Jun 16 07:08:12.657568 2019] [自动索引:错误] [pid 32210] [客户端138.99.101.198:49444] AH01276:无法提供目录/ var / www / html /:没有匹配的DirectoryIndex(index.html,index (.php),并由Options指令禁止服务器生成的目录索引 [Sun Jun 16 09:09:49.507235 2019] [autoindex:error] [pid 32209] [客户端170.130.187.26:54699] AH01276:无法提供目录/ var / www / html /:没有匹配的DirectoryIndex(index.html,index (.php),并由Options指令禁止服务器生成的目录索引 [Sun Jun 16 09:10:47.289063 2019] [autoindex:error] [pid 32207] [client 190.29.16.112:57449] AH01276:无法提供目录/ var / www / html /:没有匹配的DirectoryIndex(index.html,index (.php),并由Options指令禁止服务器生成的目录索引 [Sun Jun 16 13:50:02.964126 2019] [autoindex:error] [pid 32209] [客户端95.141.135.6:34567] AH01276:无法提供目录/ var / www / html /:没有匹配的DirectoryIndex(index.html,index (.php),并由Options指令禁止服务器生成的目录索引 [Sun Jun 16 14:27:36.383175 2019] [autoindex:error] [pid 32207] [客户端139.162.119.197:35716] AH01276:无法提供目录/ var / www / html /:没有匹配的DirectoryIndex(index.html,index (.php),并且Options指令禁止服务器生成的目录索引

“ Options指令禁止的服务器生成的目录索引”使我相信可以通过httpd.conf进行更改吗?

理想情况下,浏览器中的输出将与我在ssh终端中获得的输出相匹配

感谢和问候

1 个答案:

答案 0 :(得分:0)

我认为您的PHP版本可能未更新,并且在我的电脑中尝试了它,并且工作正常。尝试更新PHP