Asterisk AGI php-cgi

Hello.
I have a problem with asterisk and AGI.

My AGI script is this (call.cgi):

#!/usr/bin/php-cgi -q

<?php
set_time_limit(0);
require(‘phpagi.php’);
$agi = new AGI();
$agi->answer();
$agi->hangup();
?>

And my inbound extension this:

exten => 12345678,1,Wait(5)
exten => 12345678,1,AGI(call.cgi)

The AGI debug is this:

AGI Debugging Enabled
<Dongle/dongle0-0100000018>AGI Tx >> agi_request: call.cgi
<Dongle/dongle0-0100000018>AGI Tx >> agi_channel: Dongle/dongle0-0100000018
<Dongle/dongle0-0100000018>AGI Tx >> agi_language: en
<Dongle/dongle0-0100000018>AGI Tx >> agi_type: Dongle
<Dongle/dongle0-0100000018>AGI Tx >> agi_version: 11.12.0
<Dongle/dongle0-0100000018>AGI Tx >> agi_callerid: XXXXXXX
<Dongle/dongle0-0100000018>AGI Tx >> agi_calleridname: dongle0
<Dongle/dongle0-0100000018>AGI Tx >> agi_callingpres: 0
<Dongle/dongle0-0100000018>AGI Tx >> agi_callingani2: 0
<Dongle/dongle0-0100000018>AGI Tx >> agi_callington: 0
<Dongle/dongle0-0100000018>AGI Tx >> agi_callingtns: 0
<Dongle/dongle0-0100000018>AGI Tx >> agi_rdnis: unknown
<Dongle/dongle0-0100000018>AGI Tx >> agi_context: from-pstn
<Dongle/dongle0-0100000018>AGI Tx >> agi_priority: 1
<Dongle/dongle0-0100000018>AGI Tx >> agi_enhanced: 0.0
<Dongle/dongle0-0100000018>AGI Tx >> agi_accountcode:
<Dongle/dongle0-0100000018>AGI Tx >>
<Dongle/dongle0-0100000018>AGI Rx << Content-type: text/html
<Dongle/dongle0-0100000018>AGI Tx >> 510 Invalid or unknown command
<Dongle/dongle0-0100000018>AGI Rx <<
<Dongle/dongle0-0100000018>AGI Tx >> 510 Invalid or unknown command
<Dongle/dongle0-0100000018>AGI Rx << require “luci.cacheloader”
<Dongle/dongle0-0100000018>AGI Tx >> 510 Invalid or unknown command
<Dongle/dongle0-0100000018>AGI Rx << require “luci.sgi.cgi”
<Dongle/dongle0-0100000018>AGI Tx >> 510 Invalid or unknown command
<Dongle/dongle0-0100000018>AGI Rx << luci.dispatcher.indexcache = “/tmp/luci-indexcache”
<Dongle/dongle0-0100000018>AGI Tx >> 510 Invalid or unknown command
<Dongle/dongle0-0100000018>AGI Rx << luci.sgi.cgi.run()
<Dongle/dongle0-0100000018>AGI Tx >> 510 Invalid or unknown command
[Feb 3 14:05:09] ERROR[2557][C-00000018]: utils.c:1339 ast_carefulwrite: write() returned error: Broken pipe

i inspect that the script that runs is this one “/www/cgi-bin/luci”

with this content:

#!/usr/bin/lua
require "luci.cacheloader"
require "luci.sgi.cgi"
luci.dispatcher.indexcache = "/tmp/luci-indexcache"
luci.sgi.cgi.run()

very different from mine.

The config for AGI directory in asterisk.conf
astagidir => /usr/lib/asterisk/agi-bin

can you help me with this?

I cannot run php AGI script .
It redirects to the “/www/cgi-bin/luci”, propably localhost

I am running openwrt

Thank you

The web server is serving the script file rather than running it. You need to fix the web server configuration so that it treats the script as a CGI executable, not a data file.