从php shell_exec()运行节点js
您好,我打碎了一些文件来parsing由node js
parsing的文件。 目前我从terminal运行它作为node app.js
我需要从我的PHP模型中调用它。
我在想shell_exec()
函数将有所帮助。 我试过这样
shell_exec('http://172.18.18.219/hrms_work/web/uplodedfiles/test/code4goal-resume-parser/app.js');
但它不起作用。
- 你的
shell_exec
参数是错误的。 这个说法在你的terminal上工作? 可能不是因为是一个简单的链接。 - 您的文件
app.js
具有运行Apache用户的正确权限?
在回答这些问题之后,请确保您在schell_exec()
input正确的参数: app.js
的绝对path您在terminal中使用的相同命令我认为是node app.js
像schell_exec(node /absolute/path/to/app.js);
请告诉我们 ;)
你没有执行任何命令,这就是为什么它不起作用。 shell_exec()
采取正是你要写在terminal,所以这应该更好地shell_exec('node app.js')
。 但是,您也必须cd
到正确的目录或提供app.js
的绝对path。 你正在使用一个URL app.js
,我不知道node
可以像这样运行一个远程文件。