douzhouhan4618 2019-06-17 06:28
浏览 169

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

The following pieces of code when executed using php -f phptest.php gave the output (server is a GCP virtual instance running Centos7):

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

In the terminal window. On the other hand the same code when run using the server IP and appropriate URL gives:

string(0) ""

Here are the two scripts :

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

and

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

The server doesn't have a directory /var/log/apache2/error.log. Instead i was able to find /var/log/httpd/error_log which contains the following:

[Sun Jun 16 05:04:34.269345 2019] [auth_digest:notice] [pid 21434] AH01757: generating secret for digest authentication ... [Sun Jun 16 05:04:34.284400 2019] [lbmethod_heartbeat:notice] [pid 21434] AH02282: No slotmem from mod_heartmonitor [Sun Jun 16 05:04:34.284500 2019] [mpm_prefork:notice] [pid 21434] AH00163: Apache/2.4.6 (CentOS) PHP/7.3.6 configured -- resuming normal operations [Sun Jun 16 05:04:34.284505 2019] [core:notice] [pid 21434] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND' [Sun Jun 16 05:11:53.245377 2019] [autoindex:error] [pid 32206] [client 187.10.191.110:35833] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive [Sun Jun 16 07:08:12.657568 2019] [autoindex:error] [pid 32210] [client 138.99.101.198:49444] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive [Sun Jun 16 09:09:49.507235 2019] [autoindex:error] [pid 32209] [client 170.130.187.26:54699] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive [Sun Jun 16 09:10:47.289063 2019] [autoindex:error] [pid 32207] [client 190.29.16.112:57449] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive [Sun Jun 16 13:50:02.964126 2019] [autoindex:error] [pid 32209] [client 95.141.135.6:34567] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive [Sun Jun 16 14:27:36.383175 2019] [autoindex:error] [pid 32207] [client 139.162.119.197:35716] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive

'server-generated directory index forbidden by Options directive' leads me to believe that this could possibly be changed through httpd.conf possibly?

Ideally the output in the browser would match the one I get in the ssh terminal

Thanks and Regards

  • 写回答

1条回答 默认 最新

  • douqi2804 2019-06-17 10:33
    关注

    I think maybe your PHP version is not updated and I tried in my pc and it is working fine. Try to update PHP

    评论

报告相同问题?

悬赏问题

  • ¥15 鸿业暖通修改详细负荷时闪退
  • ¥15 有偿求码,CNN+LSTM实现单通道脑电信号EEG的睡眠分期评估
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体