0

Problem: Getting Warning: exec(): Unable to fork with hello.js

Question: How can I make it work?

Description: I'm trying to make phantomJs work on a Windows server. I have the following files on the public_html folder:

  1. phantomjs.exe
  2. index.php
  3. hello.js

Where index.php is simply:

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

And hello.js is:

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

When I run index.php I get the following error:

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

The code above is currently hosted here.

Question: how can I make it work?

2 Answers 2

1

Could be permissions on phantomjs.exe, have you tried changing them? http://php.net/manual/en/ref.exec.php#32601 Could be helpful

Also, have you tried using a full path?

Must say however, an exe in public_html sounds risky to me.. I think (with the wrong permission config) that anybody could execute that remotely, and possibly pass a path to any file on your server, including non public files.

Cannot think of any reason it would need to specifically go there rather than in a safer non web accessible location.

Sign up to request clarification or add additional context in comments.

1 Comment

Unfortunately I don't have a lot of control over the server at the moment, so permissions could be an issue. However, I could change the permissions on all files to 766, but I still got the same error. Right now I'm trying to create a WAMP on EC2 to further investigate on that. I also tried using full paths in many different ways, but the problem still occurred. On the security issue, I'm new to this thing so I really don't know how to deal with it, do you know any good resource to read about websecurity?
0

In fact this is probably related to memory, not permissions. Here a question regarding the same issue.

It could be a leak somewhere else in your code, however phantomjs itself has some issues with memory consuming.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.