以下代码片段在使用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运行时,相同的代码提供:
字符串(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:
孙俊16 05:04:34.269345 2019PID 21434 AH01757:生成摘要鉴权密钥...孙俊16 05:04:34.284400 2019年pid 21434 AH02282: No slotmem mod_heartmonitor 2019年AH00163: Apache/2.4.6 (CentOS) PHP/7.3.6已配置--恢复正常运行孙俊16 05:04:34.284505 2019年pid 21434 AH00094:命令行:'/usr/sbin/httpd -D前台‘孙俊16 05:11:53.245377 2019年pid 32206 AH01276:无法服务目录/var/www/ DirectoryIndex /:找不到匹配的DirectoryIndex (index.html,index.php),并且Options指令禁止的服务器生成的目录索引被Options指令孙俊16 07:08:12.657568 2019PID 32210 AH01276: Cannot serve directory /var/www/html/:找不到匹配的DirectoryIndex (index.html,index.php),并且Options指令禁止的服务器生成的目录索引DirectoryIndex 16 09:09:49.507235 2019PID 32209 AH01276: Cannot serve directory /var/www/html/:找不到匹配的DirectoryIndex (index.html,index.php),并且Options指令禁止的服务器生成的目录索引被Options指令孙俊16 09:10:47.289063 2019PID 32207 AH01276: Cannot serve directory /var/www/html/:找不到匹配的DirectoryIndex (index.html,index.php),并且Options指令禁止的服务器生成的目录索引DirectoryIndex 16 13:50:02.964126 2019PID 32209 AH01276: Cannot directory /var/www/html/:没有找到匹配的DirectoryIndex (index.html,index.php),和服务器生成的目录索引被Options指令禁止16 14:27:36.383175 2019PID 32207 AH01276: Cannot serve directory /var/www/html/:找不到匹配的DirectoryIndex (index.html,index.php),以及Options指令禁止的服务器生成的目录索引
“Options指令禁止服务器生成的目录索引”让我相信这可能是可以通过httpd.conf更改的?
理想情况下,浏览器中的输出应该与我在ssh终端中得到的输出相匹配。
感谢并致以问候
发布于 2019-06-17 18:33:19
我想可能你的PHP版本没有更新,我在我的pc上试过了,它工作得很好。尝试更新PHP
https://stackoverflow.com/questions/56625753
复制相似问题