Asterisk and FreePBX work
Contents
Setting up FreePBX to communicate with VeVoIP
The idea behind getting FreePBX to talk to VeVoIP is actually straightforward: set up a new SIP peer at VeVoIP, then set up a trunk on the PBX to register to it, much like having a VoIP phone register to it.
The folowing information was sent to me in a email:
Here’s a FPBX config example: https://portal.VeVoIP/config_example_freepbx_trunk.html
In the VeVoIP portal go to Peers/Trunks -> Create new SIP Peer -> Edit the peer. At the very top are your SIP credentials.
You should ensure the registration interval is set to 60-90s for optimum performance.
Once the peer is registered, go to Your DIDs -> Select DID to edit -> Set route to and route to backup to the new peer.
Let me know if you have nay further questions.
Thanks,
Cathy Utrecht
Accounts Manager
With a bit of help from URL in the email I was able to set up my FreePBX system and get it registering to VeVoIP.
FreeBPX not restarting Asterisk when “Update Config” is selected
One issue I ran into was FreePBX wasn’t restarting Asterisk whenever I updated the configuration. It took a bit to track it down.
- Clicking Update Config sends a POST request to the server:
POST /freepbx/admin/ajax.php?command=reload
- The request is handled by
admin/ajax.php
, which sends it todoRequest($module, $command)
-
doRequest
is handled byadmin/libraries/BMO/Ajax.class.php
, which examines the module and command, performs authorization checks, and invokes the required module and method. Because only$command
was specified, the module defaults toframework
. - The framework module is in
admin/libraries/BMO/Framework.class.php
. In that file I saw thereload
request calls a function nameddo_reload()
. -
do_reload
is found inadmin/functions.inc.php
. It does a fair amount of work:- Calls a pre-reload function if one is needed
- Runs
/path/to/asterisk/var/lib/bin/retrieve_conf --json
- Ensures an Asterisk Management Interface (AMI) object has been instantiated
- If so, invokes its
Reload()
method - Calls a post-reload function if one is needed
- I spent some time tracing through
retrieve_conf
, only to discover that its cryptic output is actually the only thing the program writes to stdout:
Please update your modules and reload Asterisk by browsing to your server.
do_reload
merely checks the return code. Because it was 0 (indicating no errors) the function proceeded to call the AMI object’sReload
method - The AMI object’s code is in
admin/libraries/php-asmanager.php
. TheReload
method checks to see if a module has been passed as a parameter:- If so, calls
$this->send_request('Reload')
- If not, shells out and runs
asterisk -rx 'core reload'
- If so, calls
- Because a module name (object?) wasn’t passed, the Reload code shelled out and ran the asterisk command directly. And that’s where things went wrong.
- The main asterisk program is started by root (although it runs as the asterisk user) and its pipe file is owned by root with only owner write permissions. But FreePBX runs as user apache, and as such couldn’t write the reload command to asterisk’s control file.
The fix was to add a new section to /opt/asterisk/etc/asterisk/asterisk.conf
:
[files] ; Changing the following lines may compromise your security ; Asterisk.ctl is the pipe that is used to connect the remote CLI ; (asterisk -r) to Asterisk. Changing these settings change the ; permissions and ownership of this file. ; The file is created when Asterisk starts, in the "astrundir" above. astctl = asterisk.ctl astctlowner = asterisk astctlgroup = apache astctlpermissions = 0660
FreePBX User Control Panel not starting
[root@fenoras2 tmp]# node /var/www/freepbx-14.0.11/admin/modules/ucp/node/index.js Starting FreePBX...FreePBX is Ready! Asterisk version is: 16.5.0 Loading all UCP Modules... fs.js:904 return binding.readdir(pathModule._makeLong(path), options.encoding); ^ Error: ENOENT: no such file or directory, scandir './modules' at Object.fs.readdirSync (fs.js:904:18) at Object.loadModules (/var/www/freepbx-14.0.11/admin/modules/ucp/node/lib/freepbx.js:158:16) at EventEmitter.<anonymous> (/var/www/freepbx-14.0.11/admin/modules/ucp/node/index.js:21:10) at emitNone (events.js:106:13) at EventEmitter.emit (events.js:208:7) at /var/www/freepbx-14.0.11/admin/modules/ucp/node/lib/freepbx.js:44:11 at EventEmitter.<anonymous> (/var/www/freepbx-14.0.11/admin/modules/ucp/node/lib/freepbx.js:130:4) at emitNone (events.js:106:13) at EventEmitter.emit (events.js:208:7) at emitNone (events.js:111:20) [root@fenoras2 tmp]#
“Build your own” abandoned; trying a VM on penguin
Given the issues I had run into trying to get FreePBX running smoothly, it appears that Sangoma, the company currently sponsoring FreePBX, has been putting its effort into getting its own version running well at the expense of having FreePBX stand on its own. It’s also possible my decision to try using PHP 7 instead of PHP 5 is causing subtle problems.
So I decided to take a different tack. Red Hat Enterprise 7, of which CentOS 7 is basically a clone, has virtualization built into it. It may not be a polished as VMware or Proxmox, but it is able to handle completely contained virtual machines.