Piyush Piyush - 5 months ago 102
Node.js Question

Run node js from php shell_exec()

Hi I uploded some files to parse which parsed by

node js
. currently I am running it from terminal as
node app.js
.

I need to call it from my php model.

I am thinking
shell_exec()
function will help. I tried like this

shell_exec('http://172.18.18.219/hrms_work/web/uplodedfiles/test/code4goal-resume-parser/app.js');


but it dose not work.

Answer
  1. your shell_exec argument is wrong. This argument works on your terminal? Probably not because is a simple link.
  2. Your file app.js has the correct permissions to run Apache user?

After answering these questions, make sure you enter the correct argument in schell_exec(): absolute path to app.js an the same command you use in terminal I think is node app.js.

something like schell_exec(node /absolute/path/to/app.js);

please let us know ;)

Comments