Getting PHP working for Asterisk 1.2.14

Hi: I’m new to asterisk, fairly familiar with software in general. I’ve purchased a Voicetronix 4 port fxo card, installed asterisk 1.2.14 on a Ubuntu server, the demo works fine. I’ve also installed Apache2, MYSQL and PHP5, they work fine, eg. i can put <?php "Hello world" ?> in a webpage, and when accessing from another machine, it prints “Hello World”. I’ve also purchased 3 books on asterisk, including the O’Reily book by Meggen, Smith and Madsen and read it through. However…

When I copy exactly the book’s demo of a php AGI program (Weather Report) to file weather1.php in /etc/lib/asterisk/agi-bin/ , chmod +x on it, and put the line

exten => s,n,DeadAGI(weather1.php)

in extensions.conf in the appropriate context, with verbose 3 and debug on, and call the test line from an outside phone, Asterisk sees the call, puts lines up at the CLI prompt indicating it receives the call, executes the .php AGI program, and gets return code of zero, but there is no action by the PHP program itself. I’ve tried putting test messaging into the .php code, still see nothing. I’ve tried putting

exten => s,n,Answer()

before or after the DeadAGI call, only effect is I can hear Asterisk answering the line, but nothing else. I’ve studied the /var/log/asterisk/messages file but can see no evidence of anything I’m doing in PHP. Is that the right place to be looking?

What am I missing? I’ve done apt-cache search (es) for anything to do with PHP and CLI, and installed everything that seems reasonable. Is Asterisk 1.2.14 able to work with PHP5? Where should I go looking for PHP’s writes to STDERR? STDOUT?

Could anyone point out to me a very minimal, simple PHP AGI program which eg. says “Hello World” via Asterisk CLI, and tell me how to debug it?

I’ve seen other PHP programs which open a pointer and ues that for outputting commandsm form

$myagi = new AGI();

$myagi->verbose(“Unable to connect to mysql database …”);

I can’t raise any response using that format to say “Hello World” either. Is that valid / better / ??

Thanks.
:blush:

hi lengould,

So, lengould your php file is not executing. If I am right then the problem is only that, add following line as a first line of your php file.

[code]<?php

#!/usr/bin/php5 -q
.
.
.
?>[/code]

and It should work.

If not worked then, copy whole code of php file and paste into another file.
remove source file from system and rename destination file (in which you was copied the code) as source file name and give again a proper permission (#> chmod 755 filename)

and then try.

I think it should work.

If not then post the proper console output of asterisk.

Regards,
Deepen