如何在PHPWeb服务器中编写python脚本
我正在尝试从php执行python脚本,在本地服务器上运行良好。 但在网络上托管之后,我遇到了如下错误:如何在PHPWeb服务器中编写python脚本,php,python,web,Php,Python,Web,我正在尝试从php执行python脚本,在本地服务器上运行良好。 但在网络上托管之后,我遇到了如下错误: "Warning: shell_exec() has been disabled for security reasons in/home/a1608290/public_html/searc2.php on line 58" 有没有办法在php web服务器中执行python脚本 链接到我的网站: 在php中,我是如何运行python脚本的: $tmp =`/usr/bin/python
"Warning: shell_exec() has been disabled for security reasons in/home/a1608290/public_html/searc2.php on line 58"
有没有办法在php web服务器中执行python脚本
链接到我的网站:
在php中,我是如何运行python脚本的:
$tmp =`/usr/bin/python2.7 wiki.py .$var`;
或
对于这两种方式,我都得到了类似的错误
提前感谢原因
您的PHP配置不允许使用shell\u exec()
函数。这是PHP在安全模式下运行时禁用的函数之一
解决方案
一般来说,我不建议您为生产环境禁用安全模式。您可以使用ini\u set
在当前会话中启用shell\u exec
,这样您就不会将服务器暴露在危险位置
<?php
$old_settings = explode(',', ini_get('disable_functions'));
$new_settings = implode(',', array_diff($old_settings, ['shell_exec']));
ini_set('disable_functions', $new_settings);
?>
以下是。我认为000webhost不允许您在其服务器上运行python脚本。它们的免费宿主不包括执行python脚本。如果你想这样做,你将不得不购买一个托管服务,允许这一点。
<?php
$old_settings = explode(',', ini_get('disable_functions'));
$new_settings = implode(',', array_diff($old_settings, ['shell_exec']));
ini_set('disable_functions', $new_settings);
?>