服务器上的PhantomJS - PHP exec无法分叉

时间:2015-02-21 16:59:02

标签: javascript php windows phantomjs

问题:使用Warning: exec(): Unable to fork

获取hello.js

问题:我该如何使其发挥作用?

说明 我正在尝试让phantomJs在Windows服务器上运行。我在public_html文件夹中有以下文件:

  1. phantomjs.exe
  2. 的index.php
  3. hello.js
  4. index.php只是:

    <?php $response = exec('phantomjs.exe hello.js');
    

    hello.js是:

    console.log("Hello world!");
    phantom.exit();
    

    当我运行index.php时,我收到以下错误:

    Warning: exec(): Unable to fork [phantomjs.exe hello.js] in D:\sites\creditflow.com\public_html\index.php on line 1 
    

    上面的代码目前已托管here

    问题:我该如何使其发挥作用?

2 个答案:

答案 0 :(得分:1)

可能是phantomjs.exe的权限,您是否尝试过更改它们? http://php.net/manual/en/ref.exec.php#32601可以提供帮助

另外,您是否尝试使用完整路径?

但是必须说,public_html中的exe对我来说听起来有风险..我认为(使用错误的权限配置)任何人都可以远程执行,并且可能会将路径传递给您的任何文件服务器,包括非公共文件。

无法想到它需要专门去那里而不是更安全的非网络访问位置。

答案 1 :(得分:0)

实际上这可能与内存有关,而与权限无关。 Here关于同一问题的问题。

它可能是代码中其他地方的泄漏,但是phantomjs itself has some issues with memory consuming