[asterisk-users] Using PHP to reload extensions

Steve Totaro stotaro at first-notification.com
Wed Oct 3 21:19:47 CDT 2007


Steve Totaro wrote:
> Michael Munger wrote:
>>
>> I am trying to use PHP to reload the extensions in an Asterisk 
>> installation. I keep getting this error:
>>
>> Unable to connect to remote asterisk (does /var/run/asterisk.ctl 
>> exist?) when I run the script by visiting the URL; however, if I run 
>> the script from the command line, it runs just fine (works perfect, 
>> actually).
>>
>> I think it is permissions related. Does anyone have any ideas?
>>
>> <php
>>         $output = shell_exec('asterisk -rx"extensions reload"');
>>         echo $output;
>> ?>
>>
>>  
>>
>> Yours,
>>
>> Michael Munger, dCAP
>>
>> 404-438-2128
>>
>> michael at highpoweredhelp.com <mailto:michael at highpoweredhelp.com>
>>
>>  
>>
>
> If running a script from a browser, it is usually run as "nobody", 
> from the command line it is whatever user you are, probably root.
>
> Thanks,
> Steve Totaro
>
Easiest way without compromising security or changing permissions.  Use 
the AMI.

1. Download phpagi (Just google it)
2. Use it to connect to the Manager interface
3. Use it to issue:
Action: Command
Command: reload

phpagi actually has a method in the manager class to do this. Just use 
the "Command" function with a parameter of "reload"

More here:
http://forums.digium.com/viewtopic.php?p=17773&sid=5f0e99c1da924a959285fcb3f81feae6



More information about the asterisk-users mailing list