运行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.phphello world的来源:http://www.eder.us/projects/phpagi/phpagi/api-docs/__examplesource/exsource_home_html_projects_phpagi_phpagi_examples_dtmf.php_acb7257145e4a5249182c8373cd8e848.html
发布于 2013-04-01 19:52:02
Exec格式错误来自/bin/bash,asterisk将hello_world.php作为bash脚本执行。
shebang
如果您添加了正确的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")中调用它。
确保外壳脚本是可执行的chmod +x hello_world.sh。
发布于 2013-07-14 22:45:15
我在顶层脚本中添加了下面这行代码,以便让它为我工作
#!/usr/bin/php -q发布于 2013-03-31 02:45:59
您的问题不是星号问题,而是一般的linux问题。
请从命令行尝试执行以下操作:
su asterisk -c "/var/lib/asterisk/agi-bin/hello_world.php"最可能的原因是: php路径不正确或selinux已启用但未配置。
https://stackoverflow.com/questions/15713359
复制相似问题