FreePBX 14 and Asterisk 13 on Debian 8 Issue

I have installed a Debian 8 container with FreePBX 14 and Asterisk 13 using the instructions in the WIKI and creating the startup script also from the WIKI for that. The only problem I ran into was the PEAR server not being available because of the hack, so I had to install Console_Getopt manually. Not sure if I did it correctly or not but PEAR thinks it’s there…

root@template:~# pear list
Installed packages, channel pear.php.net

Package Version State
Archive_Tar 1.4.4 stable
Console_Getopt 1.4.1 stable
PEAR 1.10.7 stable
Structures_Graph 1.1.1 stable
XML_Util 1.4.3 stable

Other than that the install went without a hitch. I’m having several problems that may all be related to one.

First, Asterisk does not start when using systemctl (hangs for about 2 minutes)…

root@template:~# systemctl start freepbx
Job for freepbx.service failed. See ‘systemctl status freepbx.service’ and ‘journalctl -xn’ for details.

root@template:~# systemctl status freepbx.service
● freepbx.service - FreePBX VoIP Server
Loaded: loaded (/etc/systemd/system/freepbx.service; enabled)
Active: failed (Result: exit-code) since Thu 2019-02-21 23:52:02 EST; 12s ago
Process: 1262 ExecStart=/usr/sbin/fwconsole start -q (code=exited, status=1/FAILURE)
Main PID: 1262 (code=exited, status=1/FAILURE)

Feb 21 23:52:02 template fwconsole[1262]: In Start.class.php line 187:
Feb 21 23:52:02 template fwconsole[1262]: Unable to connect to Asterisk. Did it start?
Feb 21 23:52:02 template fwconsole[1262]: start [–pre] [–post] [–skipchown] [–] []…
Feb 21 23:52:02 template systemd[1]: freepbx.service: main process exited, code=exited, status=1/FAILURE
Feb 21 23:52:02 template systemd[1]: Failed to start FreePBX VoIP Server.
Feb 21 23:52:02 template systemd[1]: Unit freepbx.service entered failed state.

And ps doesn’t show Asterisk running.

When I try and start it using fwconsole…

root@template:~# fwconsole start
Running FreePBX startup…
Taking too long? Customize the chown command, See http://wiki.freepbx.org/display/FOP/FreePBX+Chown+Conf
Setting Permissions…
Setting base permissions…Done
Setting specific permissions…
11428 [============================]
Finished setting permissions
Starting Asterisk…
[--------------->------------] 1 min
In Start.class.php line 187:
Unable to connect to Asterisk. Did it start?
start [–pre] [–post] [–skipchown] [–] []…

Checked ps, not running.

But if I re-run systemctl start freepbx, it runs!

However, if I hit the interface to start the setup, the Initial Setup screen appears, but at the top right corner in a red box: Can Not Connect to Asterisk, even though I know its running…

2042 pts/0 S 0:00 /bin/sh /usr/sbin/safe_asterisk -U asterisk -G asterisk
2044 pts/0 Sl 0:06 /usr/sbin/asterisk -f -U asterisk -G asterisk -vvvg -c

If I attempt a fwconsole restart…

root@template:~# fwconsole restart
Running FreePBX shutdown…
In php-asmanager.php line 489:
fclose(): 92 is not a valid stream resource
restart [-i|–immediate] [–] []…

So here are my manager settings:

template*CLI> manager show settings

Global Settings

Manager (AMI): Yes
Web Manager (AMI/HTTP): No
TCP Bindaddress: 0.0.0.0:5038
HTTP Timeout (seconds): 60
TLS Enable: No
TLS Bindaddress: Disabled
TLS Certfile: asterisk.pem
TLS Privatekey:
TLS Cipher:
Allow multiple login: Yes
Display connects: No
Timestamp events: No
Channel vars:
Debug: No

And the manager.conf:

[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0
displayconnects=no ;only effects 1.6+

[admin]
secret =
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message
write = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message
writetimeout = 5000

And here is is listening…

root@template:~# netstat -an | grep 5038
tcp 0 0 0.0.0.0:5038 0.0.0.0:* LISTEN

If I try to stop the service using systemctl, I get no error, but Asterisk is still running. Asterisk CLI works. So PHP can’t talk to Asterisk.

So I’m not sure if its a faulty Console_Getopt install, Asterisk problem, PHP, etc. Any help would be greatly appreciated! I’ll provide any missing info. Thanks in advance!

-Mike Walker

FreePBX needs to start Asterisk not have Asterisk running already. You need to check what user Asterisk is running as, as well.

asterisk -rx “core stop” <-- This will turn off Asterisk
fwconsole stop <-- Make sure FreePBX is shutdown
fwconsole chown <-- This will make sure files have the right permissions/ownership
fwconsole start <-- Start FreePBX which will start Asterisk properly.

Make sure

/etc/default/asterisk

Has asterisk as user and group

Fixed since there is nothing for Asterisk put in /etc/default.

I would beg to differ that it would be empty if the OP installed asterisk in a Debian system.

Well then I’ve learned something new. Someone who has experience with Debian might want to update the wiki with this. Because if this is a thing that Debian does and puts things in that folder that need to have the proper permissions fwconsole chown will probably not get it since that isn’t a directory path used in other installs, specially Distro/CentOS/RHEL ones.

With Debian (of any version) and if /etc/default/apache2 and /etc/default/asterisk both have the same user and group, preferably asterisk, then asterisk will start without fwconsole ( or even amportal for the laggards), if needed
later, fwconsole can still be used , including “fwconsole chown” or “fwconsole r”

If using systemctl to start asterisk, then make sure asterisk.service has

ExecStart=/usr/sbin/asterisk -f -U asterisk -G asterisk

There is no /etc/default/asterisk file. I don’t see runas user in asterisk.conf. Not sure how it knows to run -u asterisk -g asterisk, but ps shows this…

2042 pts/0 S 0:00 /bin/sh /usr/sbin/safe_asterisk -U asterisk -G asterisk
2044 pts/0 Sl 0:06 /usr/sbin/asterisk -f -U asterisk -G asterisk -vvvg -c

After a fresh reboot, when asterisk is not running, and I do a fwconsole start, it tries to start asterisk but times out…

root@template:~# fwconsole start
Running FreePBX startup…
Setting Permissions…
Setting base permissions…Done
Setting specific permissions…
11428 [============================]
Finished setting permissions
Starting Asterisk…
[--------------->------------] 1 min
In Start.class.php line 187:
Unable to connect to Asterisk. Did it start?

Yes it DID start, I can see it running as the asterisk user. So how come fwconsole can’t tell asterisk is running after it starts it?

Now if I do a fwconsole restart or fwconsole stop, I get an fclose error…

root@template:/etc/asterisk# fwconsole restart
Running FreePBX shutdown…
In php-asmanager.php line 489:
fclose(): 92 is not a valid stream resource

Why, if Asterisk is running as the asterisk user, can’t fwconsole talk to Asterisk, just as Apache/PHP can’t tell its running when on the Initial Setup screen?

I’ve been building FreePBX systems on Debian (7, 8, and now 9) for the past five years. You might find some useful information in my installation script which is located at:

https://www.dslreports.com/forum/r30661088-PBX-FreePBX-for-the-Raspberry-Pi

Turns out you can’t use a minimal Debian VPS template as there was apparently a package or two missing. Using the standard template solved this problem. Thanks everyone.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.