运行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
答案 0 :(得分:4)
Exec Format Error来自/bin/bash
,星号作为bash脚本执行hello_world.php
。
<强>认领强>
如果添加正确的shebang,脚本将由给定的PHP解释器执行。 第一行告诉系统哪个程序应运行脚本。
#!/usr/bin/env php
要测试你的shebang,请执行脚本本身,而不是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
替代包装
创建一个执行PHP脚本的bash脚本。
示例hello_world.sh:
/usr/bin/php hello_world.php
并在拨号方案AGI("hello_world.sh")
中调用它。
确保shellscript是可执行的chmod +x hello_world.sh
。
答案 1 :(得分:2)
我在顶级脚本上添加了以下行以使其适合我
#!/usr/bin/php -q
答案 2 :(得分:1)
你的问题不是星号问题,而是一般的linux问题。
请尝试从以下命令行开始:
su asterisk -c "/var/lib/asterisk/agi-bin/hello_world.php"
最可能的原因:php路径不正确或启用了selinux且未配置。
答案 3 :(得分:0)
您是否可以检查extensions.conf
或extensions_custom.conf
,如果扩展名和优先级不连续,也会发生此错误。
请查看以下示例:
[context]
exten => 1,1,Answer()
exten => 1,2,AGI(your-agi-script)
exten => 1,3,Hangup()