我正在使用AGI(Asterisk网关接口)从拨号计划运行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);
?>`
agi设置调试的cli输出为
` -- <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`
这意味着文件包括其他文件或库,这些文件或库无法从此目录访问(可能不是使用的完整路径)
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
在Centos上运行良好。您需要确保在星号.conf上正确列出了指向文件夹astagidir=>/usr/share/agister/agi-bin的路径,该文件夹是您的默认agi-bin文件夹。此外,还需要去依赖性。我尝试过其他linux版本,但也遇到了同样的问题。确保您可以从shell运行php-v,否则在您的php程序中,请在头中使用php-cli而不是#/usr/bin/php。最后一件事,需要正确添加PATH,这样它就可以从任何地方运行,否则你需要在extensions.conf上使用完整路径(调用你的php脚本完整路径/var/lib/agister/agi-bin/agiscript.php,以便它在星号CLI设置为调试的情况下进行处理,看看它是否找到了它。这很痛苦,但一旦它工作了,就很好了。