PHP的exec()不能正常工作 [英] PHP exec() not working properly

查看:126
本文介绍了PHP的exec()不能正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有PHP的exec()函数的困难。这似乎不能调用某些功能。例如,code 回声EXEC('LS'); 不产生任何输出(它应该有目录中的文件)。这主要的原因,这是我的一个问题是,我想从PHP的exec执行的.jar()调用。

I am having difficulty with the PHP exec() function. It seems to not be calling certain functions. For instance, the code echo exec('ls'); produces no output whatsoever (it should, there are files in the directory). That main reason this is a problem for me is that I'm trying execute a .jar from a PHP exec() call.

据我知道我在正确调用java程序,但我没有得到任何输出。该.jar可以从服务器上的命令行来执行。 (根据记录,这是一个Apache服务器)。

As far as I know I'm calling the java program properly, but I'm not getting any of the output. The .jar can be executed from the command line on the server. (For the record, it's an apache server).

我对PHP的.jar执行这样的容貌:

My php for the .jar execute looks like this:

$output = array();
exec('java -jar testJava.jar', $output);
print_r($output);

我得到的输出此exec()调用阵列()

我曾与EXEC执行成功()'WHOAMI'PWD'。我想不通为什么一些职能工作,有些则不是。我不是最有经验的人用PHP要么,所以我也不太清楚如何来诊断问题。任何及所有帮助将是AP preciated。

I have had success with exec() executing 'whoami' and 'pwd'. I can't figure out why some functions are working and some aren't. I'm not the most experienced person with PHP either, so I'm not too sure how to diagnose the issue. Any and all help would be appreciated.

推荐答案

我已经找到了问题 - SELinux的是访问某些功能阻止PHP。把SELinux的进入许可模式已修复的问题(虽然,我宁愿没有要离开的SELinux在许可模式下,我宁愿找允许某些功能,如果我能的一种方式)。

I have found the issue - SELinux was blocking PHP from accessing certain functions. Putting SELinux into permissive mode has fixed the issues (although, I'd rather not have to leave SELinux in permissive mode; I'd rather find a way of allowing certain functions if I can).

这篇关于PHP的exec()不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆