无法在AGI星号中执行php脚本,没有这样的文件或目录

时间:2015-06-27 17:55:42

标签: php asterisk agi

我正在使用AGI(星号网关接口)从拨号计划运行php脚本

我的拨号方案看起来像

exten =>2600,1,Playback(hello-world)

same =>n,AGI(agiscript.php)

same =>n,Hangup()

agiscript.php看起来像

`#!/usr/bin/php -q 
<?php
require_once('dbconnect.php');
db_connect();
$sql = "update oicall_main set balance='100' where username='100';";
$result = mysql_query($sql);
?>`

cli输出的agi set debug on是

 ` -- <SIP/example-00000001> Playing 'hello-world.gsm' (language 'en')
    -- Executing [2600@demo:2] AGI("SIP/example-00000001", "agiscript.php") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/agiscript.php
<SIP/example-00000001>AGI Tx >> agi_request: agiscript.php
<SIP/example-00000001>AGI Tx >> agi_channel: SIP/example-00000001
<SIP/example-00000001>AGI Tx >> agi_language: en
<SIP/example-00000001>AGI Tx >> agi_type: SIP
<SIP/example-00000001>AGI Tx >> agi_uniqueid: 1435426730.1
<SIP/example-00000001>AGI Tx >> agi_version: 13.2.0
<SIP/example-00000001>AGI Tx >> agi_callerid: example
<SIP/example-00000001>AGI Tx >> agi_calleridname: unknown
<SIP/example-00000001>AGI Tx >> agi_callingpres: 0
<SIP/example-00000001>AGI Tx >> agi_callingani2: 0
<SIP/example-00000001>AGI Tx >> agi_callington: 0
<SIP/example-00000001>AGI Tx >> agi_callingtns: 0
<SIP/example-00000001>AGI Tx >> agi_dnid: 2600
<SIP/example-00000001>AGI Tx >> agi_rdnis: unknown
<SIP/example-00000001>AGI Tx >> agi_context: demo
<SIP/example-00000001>AGI Tx >> agi_extension: 2600
<SIP/example-00000001>AGI Tx >> agi_priority: 2
<SIP/example-00000001>AGI Tx >> agi_enhanced: 0.0
<SIP/example-00000001>AGI Tx >> agi_accountcode: 
<SIP/example-00000001>AGI Tx >> agi_threadid: 140718795228928
<SIP/example-00000001>AGI Tx >> 
<SIP/example-00000001>AGI Rx << verbose "Failed to execute '/var/lib/asterisk/agi-bin/agiscript.php': No such file or directory" 1
 agiscript.php: Failed to execute '/var/lib/asterisk/agi-bin/agiscript.php': No such file or directory
<SIP/example-00000001>AGI Tx >> 200 result=1`

3 个答案:

答案 0 :(得分:0)

在Centos上运行良好。您需要确保在 asterisk.conf 上正确列出了指向该文件夹 astagidir => / usr / share / asterisk / agi-bin 的路径,并将其作为默认的 agi-bin 文件夹。还需要依赖。我尝试了其他Linux版本,但遇到了同样的问题。确保可以从外壳运行php -v,否则在您的php程序中,请在标头中使用php-cli而不是#!/ usr / bin / php。最后一件事,需要正确添加PATH,以便它可以在任何地方运行,否则,您需要在extensions.conf上使用完整路径(在php脚本中使用完整路径/var/lib/asterisk/agi-bin/agiscript.php为了使它能够与设置为asterisk的CLI一起调试以查看是否确实找到它,这是很痛苦的,但是一旦它起作用了,那就太好了。

答案 1 :(得分:-1)

该文件包含其他文件或lib,无法从此目录访问(可能不是使用的完整路径)

答案 2 :(得分:-1)

缺少php-cli或php-mysql或两者都不存在。安装它们并重新加载星号。

对于CentOS:

sudo yum install php-cli php-gd php-mysql

对于Ubuntu / Debian:

sudo apt-get install php-cli php-gd php-mysql