Linux命令无法在PHP网站上运行,但可以在终端上运行

问题描述 投票:0回答:1

当我从CWP终端进行测试时,我正在使用phantomjs及其工作。我将其安装在usr/local/share/phantomjs并同时设置环境变量

我从不同目录运行一个常见的From Terminal,以确保其正常工作:phantomjs --version //响应2.1.1

当我注册新域并创建新的用户Cpanel帐户时。从PHP中,我确保exec函数正常运行,但是当我输入命令phantomjs --version时要么phantomjs exmple.js它返回空响应。

代码:

exec("phantomjs --version",$output, $code); // $output = empty. $code = 127
exec("phantomjs example.js",$output, $code); // $output = empty. $code = 127
exec("ls",$output, $code); // (to test if exec working or not) it return files list, and its wroking  

我如何允许cpanel用户从PHP exec访问phantomjs?

服务器

Centos 7
PHP 7.2
Cpanel User: dummy
php linux phantomjs cpanel
1个回答
0
投票

尝试执行文件的直接路径。运行

whereis phantomjs

获取路径并将其传递给exec

© www.soinside.com 2019 - 2024. All rights reserved.