【问题标题】:Linux command not working from PHP website but working from terminalLinux命令不能从PHP网站工作,但可以从终端工作
【发布时间】:2020-06-08 16:16:58
【问题描述】:

当我从 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】:

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

    whereis phantomjs
    

    获取路径并将其传递给exec

    【讨论】:

    • 是的,它可以工作,但是我已经在环境中添加了路径,并且它直接从终端工作。我需要做什么才能只使用 phantomjs?
    • 这是我遵循的教程,liquidweb.com/kb/how-to-install-phantomjs-on-centos-7 及其环境变量命令 ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/本地/bin
    猜你喜欢
    • 2018-01-08
    • 1970-01-01
    • 2015-04-12
    • 2018-05-04
    • 1970-01-01
    • 1970-01-01
    • 2012-09-05
    • 2012-06-12
    • 2011-05-11
    相关资源
    最近更新 更多