Php 执行Linux shell脚本时出错
我试图在dhtmlx实时更新框架中执行一个shell脚本来启动nodejs服务器。根据dhtmlx文档,nodejs服务器将放在web根目录中。我已经在/var/www(nodejs文件夹所在的位置)中编写了一个批处理文件,这样就可以启动服务器,或者根据需要重新启动服务器,而无需打开终端:Php 执行Linux shell脚本时出错,php,linux,node.js,shell,Php,Linux,Node.js,Shell,我试图在dhtmlx实时更新框架中执行一个shell脚本来启动nodejs服务器。根据dhtmlx文档,nodejs服务器将放在web根目录中。我已经在/var/www(nodejs文件夹所在的位置)中编写了一个批处理文件,这样就可以启动服务器,或者根据需要重新启动服务器,而无需打开终端: #!/bin/bash nodejs nodejs/server.js 在脚本中,有一个对php脚本的ajax调用: $("#starter").click(function(response){
#!/bin/bash
nodejs nodejs/server.js
在脚本中,有一个对php脚本的ajax调用:
$("#starter").click(function(response){
var jqxhr = $.ajax( "./phpFunctions/nodeStarter.php" )
.done(function(response) {
alert(response);
})
.fail(function() {
alert(response);
})
});
在nodeStarter.php中,执行以下操作:
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$output = shell_exec("/var/www/nodeStart 2>&1; echo $?");
echo "<pre>$output</pre>";
unset $output;
错误报告(E|u错误| E|u警告| E|u解析);
$output=shell_exec(“/var/www/nodeStart 2>&1;echo$?”;
回显“$output”;
未结算美元产出;
以及错误消息:
嗯?似乎是在web文件夹中查找server.js,而不是在我告诉它的web根目录中。我很困惑。试试看
谢谢,成功了。在启动时发现一个php错误,unset($output);不喜欢看到任何括号。
#!/bin/bash
nodejs /var/www/nodejs/server.js