PHPAGI:Exec格式错误 [英] PHPAGI: Exec format error

查看:216
本文介绍了PHPAGI:Exec格式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行phpagi时遇到问题:

Encountering a problem when running phpagi:

-- Executing [123@DLPN_C:1] AGI("SIP/1000-00000001", "hello_world.php") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/hello_world.php
hello_world.php: Failed to execute '/var/lib/asterisk/agi-bin/hello_world.php': Exec format error
-- Auto fallthrough, channel 'SIP/1000-00000001' status is 'UNKNOWN' Scheduling destruction of SIP dialog '343930130' in 32000 ms (Method: INVITE)

从命令行:

root@asterisk-test:/var/lib/asterisk/agi-bin# php5 -q hello_world.php 
#!/usr/bin/php5 -q

其他信息:

-rwxr-xr-x  1 root     root       757 Mar 29 19:32 hello_world.php
drwxrwxr-x  4 root     root      4096 Mar 29 19:44 phpagi
-rwxr-xr-x  1 root     root     25079 Sep 30  2010 phpagi-asmanager.php
-rwxr-xr-x  1 root     root      2322 Sep 30  2010 phpagi-fastagi.php
-rwxr-xr-x  1 root     root     67615 Sep 30  2010 phpagi.php

您好世界的来源:

Source of hello world: http://www.eder.us/projects/phpagi/phpagi/api-docs/__examplesource/exsource_home_html_projects_phpagi_phpagi_examples_dtmf.php_acb7257145e4a5249182c8373cd8e848.html

推荐答案

Exec格式错误来自 / bin / bash ,星号将 hello_world.php 作为bash脚本执行。

The Exec Format Error is from /bin/bash, asterisk executes hello_world.php as a bash script.

shebang

如果添加正确的 shebang ,脚本将由给定的PHP解释器执行。
第一行告诉系统哪个程序应该运行脚本。

If you add a correct shebang, the script get executed by the given PHP intepreter. The first Line tells the System which program should run the script.

#!/ usr / bin / env php

要测试您的shebang,请执行脚本本身,而不要通过PHP:

root @ asterisk-测试:/ var / lib / asterisk / agi-bin#./hello_world.php

To test your shebang, execute the script itself, not by PHP:
root@asterisk-test:/var/lib/asterisk/agi-bin# ./hello_world.php

确保它可以通过以下命令执行:

root @ asterisk-test:/ var / lib / asterisk / agi-bin#chmod + x hello_world.php

Make sure it is executable with:
root@asterisk-test:/var/lib/asterisk/agi-bin# chmod +x hello_world.php

替代包装

创建一个执行PHP脚本的bash脚本。

Create a bash script that executes the PHP script.

示例hello_world.sh:

/ usr / bin / php hello_world.php

example hello_world.sh:
/usr/bin/php hello_world.php

并在Dialplan AGI( hello_world.sh)中调用它。

and call it in the Dialplan AGI("hello_world.sh").

确保shellscript是可执行的 chmod + x hello_world.sh

Make sure the shellscript is executable chmod +x hello_world.sh.

这篇关于PHPAGI:Exec格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆