(Unofficial) FreePBX on Pi


(Rob Thomas) #1

There’s a few ways to install FreePBX on a Pi, but they all seem overly complicated, and as a bunch of us ex-FreePBX people were all hanging out last week, I took the opportunity to grab the brain trust and throw together my Unofficial one-step FreePBX install script using the latest Raspbian (Based on Debian 10).

Enjoy!

–Rob

#!/bin/bash

wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ buster main" > /etc/apt/sources.list.d/php.list
curl -sL https://deb.nodesource.com/setup_11.x | bash -

apt-get install asterisk apache2 libapache2-mod-fcgid build-essential openssh-server apache2 mariadb-server  mariadb-client bison flex php7.0 php7.0-curl php7.0-cli php7.0-pdo php7.0-mysql php7.0-mbstring php7.0-xml curl sox  libncurses5-dev libssl-dev mpg123 libxml2-dev libnewt-dev sqlite3  libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev  libasound2-dev libogg-dev libvorbis-dev libicu-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev  libspandsp-dev sudo subversion libtool-bin python-dev unixodbc dirmngr sendmail nodejs

systemctl stop asterisk

rm -rf /etc/asterisk
mkdir /etc/asterisk
touch /etc/asterisk/{modules,cdr}.conf
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
rm -rf /var/www/html

sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.0/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
a2enmod rewrite
service apache2 restart

cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-15.0-latest.tgz
tar vxfz freepbx-15.0-latest.tgz
rm -f freepbx-15.0-latest.tgz
cd freepbx
./start_asterisk start
./install -n

High Availability (Split from another thread)
Raspberry 4 con Freepbx - Cuestions!
Thoughts on a NUC
(Jared Busch) #2

Straight to FreePBX 15?


(Rob Thomas) #3

I’m not sure what’s happening inside Sangoma with 15, but if you don’t want to run 15 you have to go back to PHP 5.6, and that’s just beating your head against a brick wall 8)


(Jared Busch) #4

Ah, PHP requirements of the Debian OS? Makes sense.

I’ve not trialled 15 on anything yet. It’s on the list of things to do “soon”


#5

Any problems with UCP on Buster on a pi?


#6

“Both FreePBX 14 and 15 only support PHP 5.6.x.”


(Itzik) #7

That seems to be true, hence Bill asked for help.

Unless I’m missing something


#8

Couple of suggestions (I did this on DO x64 Buster), you need curl before you can curl and
for sury’s stuff so you can get php7.0 and not be left with php7.3 and a fix for ucp’s need for an older version of libicu-devel

apt install ca-certificates apt-transport-https curl 
wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add -
echo "deb https://packages.sury.org/php/ buster main" | tee /etc/apt/sources.list.d/php.list
echo 'icuinfo 2>/dev/null|grep "\"version\""|sed "s/.*\">\(.*\)<.*/\1/g"' >  /usr/bin/icu-config
chmod +x  /usr/bin/icu-config
apt-get -y update

(Rob Thomas) #9

Yes and no. If you ring up support and say you’re using PHP 7 and are having problems, they’ll want you to downgrade (“supported”).

But the original point of the 15 release was to get 7 working in there. So yeah, 7.0 will work, probably 7.1, but 7.2 and higher did some major changes to the way arrays are handled and will cause a bunch of hard to find issues.


(Tom Ray) #10

I’m not sure about that. I just did this a month ago with a server, moved it to 7.2. With error reporting on, I was able to find all the errors that 7.2 complained about. Including the count errors for arrays.

There’s no point in doing any PHP 7.x stuff unless it’s all 7.2+. 7.0 is EOL, 7.1 is EOL at the end of the year so 7.2+ is the only logic version to build against. Otherwise you’re just back in the same boat, running an unsupported PHP release.

Honestly, FreePBX 15 doesn’t really excite me like v14 did. For me this is a release that was made more grandiose than it really is. I also consider this a release that is over 18 months behind as it was announce shortly after the release of v14 that there would be a six month release cycle for major version updates. Thus v15 was supposed to be public by Jan 2018 and it’s now July 2019. Which according to a six month release cycle means we should have v18 coming out now.

I mean let’s just look at v14 vs v15. We had an Alpha release of v14 in Jan 2017, Beta by March/April-ish and the Stable was released July 2017. Six months. In contrast, we waited for over a year and a half for a beta of v15 and it’s still in Beta with no time table of its release to stable.

I think that part of the problem is the lack of having a LTS release or any real plans on releases. FreePBX v13 is not really supported but is supported somewhat if you have HA because it’s the only release that still supports it. v13 will be considered officially EOL when v14 (or v15) have HA support. It’s also been 18 months on v14 having HA support that’s still no where near anything public as far as I’ve seen. So that begs the question, will v15 having proper HA support? Because I can’t see a company taking $3,000 product and killing that revenue stream for 18 months. Well I can if either 1) It’s so broken that it is unsellable. 2) It just wasn’t selling to meet quantities that make keeping it maintained and supported financially viable. 3) Combo of 1 & 2.

Again, this is just me. Not looking to start some epic battle with anyone over this.


High Availability (Split from another thread)
#11

To fix the ucp not staying alive problem, the default keys are too short for opsnssl , edit the last line of /etc/ssl/opsnssl.cfg to say 1 not 2 until you get better keys.


#12

So, I know bash scripts aren’t allowed here so what i post is not one but with a simple modification it might help those who boldly go (this works on DO/Buster)

#!/bin/nofuckingwayits a scriptforbash, if i was it would just be #!bin/bash, but it's not ;-)
# stage 1 setup base environment for DO, maybe others
#make as swap file for the needy
dd if=/dev/zero of=/.swapfile bs=1M count=1000
chmod 600 /.swapfile
mkswap /.swapfile
echo -e "/.swapfile\tswap\tswap" >> /etc/fstab
swapon -a

# get apt ready to apt
apt-get -y update
apt-get -y upgrade

# get php7.0 ready
apt install -y software-properties-common ca-certificates apt-transport-https curl gnupg2
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ buster main" > /etc/apt/sources.list.d/php.list

# install node/npm , (don't use 10+)
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs

#fix the Cementos/Debian libicu  thingy
echo 'icuinfo 2>/dev/null|grep "\"version\""|sed "s/.*\">\(.*\)<.*/\1/g"' >  /usr/bin/icu-config
chmod +x  /usr/bin/icu-config

#stage 2 install the needed debs
apt-get install -y mlocate asterisk apache2 libapache2-mod-fcgid build-essential openssh-server apache2 mariadb-server \
mariadb-client bison flex php7.0 php7.0-curl php7.0-cli php7.0-pdo php7.0-mysql php7.0-mbstring php7.0-xml \
sox libncurses5-dev libssl-dev mpg123 libxml2-dev libnewt-dev sqlite3  libsqlite3-dev pkg-config automake \
libtool autoconf git unixodbc-dev uuid uuid-dev  libasound2-dev libogg-dev libvorbis-dev libicu-dev \
libcurl4-openssl-dev libical-dev libneon27-dev libsrtp2-dev  libspandsp-dev sudo subversion libtool-bin \
python-dev unixodbc dirmngr postfix  sudo  mc traceroute rsync sngrep ffmpeg

#set a reduced security for defult freepbx keys
sed -i  's/^CipherString.*/CipherString = DEFAULT@SECLEVEL=1/' /etc/ssl/openssl.cnf

#stage 3 install FreePBX
systemctl stop asterisk
rm -rf /etc/asterisk
mkdir /etc/asterisk
touch /etc/asterisk/{modules,cdr}.conf
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
rm -rf /var/www/html
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.0/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
sed -i 's/^memory_limit.*$/memory_limit = 256M/g' /etc/php/7.0/apache2/php.ini
a2enmod rewrite
service apache2 restart
cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-15.0-latest.tgz
tar vxfz freepbx-15.0-latest.tgz
rm -f freepbx-15.0-latest.tgz
cd freepbx
./start_asterisk start
./install -n

#last stage get, the basic modules  working for UCP
fwconsole ma upgradeall
fwconsole ma downloadinstall certman
fwconsole ma downloadinstall userman
fwconsole ma downloadinstall ucp
#fix notifications so oly the good guys remain
mysql asterisk -e 'delete from notifications'
fwconsole r

#should be ready go . . .

exit 0

Currently, there is a problem with pm2 on restaring the machine, I fix it with

fwconsole downloadinstall  ucp, 

a while after boot ( do the proper systemd enable rc-local thing )

wbrtc is dependent on ucp so include that disable/enable around the downloadinstall

(Thanks to all the behind the scenes dudes who got me going on this)


#13

Rather than reinventing the wheel, there’s a fully automated script that’s been available for years:

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

The included script (install) and archive (install.tar.gz) will build
FreePBX 13, 14, or 15 plus Asterisk 13, 15, 16, or 16-GVSIP on a Raspberry Pi.
iptables, dnsmasq, and exim4 are also installed.

Installation takes a approximately 35 minutes to complete on a Raspberry Pi 4B.


(Rob Thomas) #14

If that’s Ron’s script, that compiles asterisk. That’s a terrible idea because then you don’t have all the QA resources of the distro you’re using managing security updates.

Now, some people may WANT to compile their own asterisk, and they may have some odd reason to do so, but 99% of people don’t (even if they think they do!)

The script I posted takes about 2 or 3 minutes to run, depending on your network speed.


(Jared Busch) #15

100% this.


#16

Hi Rob
nice job

will this work on the new Pi 64bit
or do you have to make some change to the script

Moz


(Lorne Gaetz) split this topic #17

6 posts were split to a new topic: High Availability (Split from another thread)


#18

So , if you want CDR’s then you are as yet SOL , an effective libmaodbc.so is for me elusive on Buster, even if compiled from source, I imagine it is also not working on any hardware platform.

Otherwise everything else works peachy.

Comments please


#19

For amd64 architecture (you said you were building on DigitalOcean), these packages work fine as referenced in the wiki: https://wiki.freepbx.org/display/FOP/Installing+FreePBX+15+on+Debian+9.6#InstallingFreePBX15onDebian9.6-InstallMariaDBODBC


#20

And the “adaptive odbc cdr/cel” /libicu (UCP) also ?

what does “fwconsole pm2 --list” issue?

Are the the cdr/cel tables being populated?

But to answer, Yes, on Stretch it all works with php5.6 or php7.0, On Debian 10 (either amd64 or arm) not so much. None will be happy with php7.+ not even Stretch

Wasn’t this whole thing started of with attempting FreePBX 15 on Buster on a Pi4 (or any cpu for that matter) ?

This is where I will wait for mariadb to catch up. . .