Install FreePBX 14 + Asterisk 14.7.7 on Debian 9.5

Installation

First, log into your newly installed Debian server as root. I'm using Digital Ocean for this install and you can use this referral link to get $10 in credit.

Check the network config:

nano /etc/network/interfaces

Verify that that a static IP has been assigned to the WAN interface and that DNS has been properly configured:

auto lo
iface lo inet loopback
        dns-nameservers  67.207.67.2 67.207.67.3

auto eth0
iface eth0 inet static
        hwaddress 00:00:00:00:00:00
        address   X.X.X.X
        netmask   X.X.X.X
        gateway   X.X.X.X
        post-up ifup eth0:1

Update & upgrade packages:

apt update && apt upgrade -y

Remove PHP 7, as FreePBX doesn't support PHP 7 to my knowledge:

* apt remove --purge php7*
* apt install curl apt-transport-https net-tools
* curl https://packages.sury.org/php/apt.gpg | apt-key add -
* nano /etc/apt/sources.list.d/suryorgapt.list

Add the following source:

deb https://packages.sury.org/php/ stretch main

Update packages again and install PHP 5 Dependencies:

* apt-get update
* apt-get install -y apache2 bison php5.6 php5.6-mbstring php5.6-curl php5.6-fpm php5.6-cli php5.6-mysql php-pear php5.6-gd php5.6-odbc curl sox libncurses5-dev libssl-dev default-libmysqlclient-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 subversion libtool-bin python-dev php5.6-xml php5.6-gd default-mysql-client default-mysql-server default-mysql-client-core default-mysql-server-core bison flex mongodb dirmngr php5.6-cgi libapache2-mod-security2 libapache2-mod-php5.6

More dependencies:

* apt-get install -y build-essential linux-headers-`uname -r`

Enable rewrite mod for Apache:

* a2enmod rewrite
* systemctl restart apache2

Download the Asterisk Source files:

* cd /usr/src
* wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
* wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz
* wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-14-current.tar.gz
* wget -O jansson.tar.gz https://github.com/akheron/jansson/archive/v2.10.tar.gz

Compile & install Janson:

* tar vxfz jansson.tar.gz
* cd jansson-*
* autoreconf -i
* ./configure
* make -j4
* make install

Compile & install Dahdi:

* cd /usr/src
* tar xvfz dahdi-linux-complete-current.tar.gz
* cd dahdi-linux-complete-2*
* make all
* make install
* make config

Compile & install LibPri:

* cd /usr/src
* tar xvfz libpri-current.tar.gz
* cd libpri-1*
* make -j4
* make install

Compile & install Asterisk:

* cd /usr/src
* tar xvfz asterisk-14-current.tar.gz
* cd asterisk-14.*
* ./contrib/scripts/install_prereq install

Enter your ITU-T telephone code (1 for US) and proceed:

* ./configure --with-pjproject-bundled
* make menuselect

Within menu select, you are able to enable more functionality, but if you are most liely oay with the default settings. For some reason the Opus codec is on the list but is unavailable during install. We'll go after enabling that later:

Screenshot_1

Exit and proceed to compile Asterisk:

* make -j4
* make install
* make config
* make samples
* ldconfig

Asters is now installed. You must reboot your system, otherwise when attempting to get into the CLI, you'll get the following output:

root@test:/usr/src/asterisk-14.7.7# asterisk -r
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)

Install Soundfiles:

* cd /var/lib/asterisk/sounds
* wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-wav-current.tar.gz
* wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz
* tar xvf asterisk-core-sounds-en-wav-current.tar.gz
* tar xfz asterisk-extra-sounds-en-wav-current.tar.gz
* wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-g722-current.tar.gz
* wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz
* tar xfz asterisk-extra-sounds-en-g722-current.tar.gz
* tar xfz asterisk-core-sounds-en-g722-current.tar.gz

Install & Configure Apache

* service asterisk stop
* groupadd asterisk
* useradd -d /var/lib/asterisk -g asterisk asterisk
* chown -R asterisk:asterisk /var/spool/asterisk /var/run/asterisk /etc/asterisk /var/{lib,log,spool}/asterisk /usr/lib/asterisk /var/www
* sed -i 's/#AST_USER="asterisk"/AST_USER="asterisk"/g' /etc/default/asterisk
* sed -i 's/#AST_GROUP="asterisk"/AST_GROUP="asterisk"/g' /etc/default/asterisk
* cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_BK
* sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
* sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
* mv /var/www/html /var/www/html.bak

Change the memory_limit to 256M in /etc/php/5.6/apache2/php.ini:

* sed -i 's|memory_limit = 128M|memory_limit = 256M|g' /etc/php/5.6/apache2/php.ini

Download and configure OBDC:

* cd /tmp
* wget http://ftp.ntu.edu.tw/MySQL/Downloads/Connector-ODBC/5.3/mysql-connector-odbc-5.3.10-linux-glibc2.12-x86-64bit.tar.gz
* tar -xvf mysql-connector-odbc-5.3.10-linux-glibc2.12-x86-64bit.tar.gz
* cp mysql-connector-odbc-5.3.10-linux-glibc2.12-x86-64bit/lib/libmyodbc5* /usr/lib/x86_64-linux-gnu/odbc/

Edit odbcinst.ini

nano /etc/odbcinst.ini

Add the following:

[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc5S.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1

Edit odbc.ini:

nano /etc/odbc.ini

Add the following:

[MySQL-asteriskcdrdb]
Description=MySQL connection to 'asteriskcdrdb' database
driver=MySQL
server=localhost
database=asteriskcdrdb
Port=3306
Socket=/var/run/mysqld/mysqld.sock
option=3

Configure Aache:

* a2enconf php5.6-fpm
* a2enmod proxy_fcgi setenvif
* service apache2 restart

Edit asterisk.conf

* nano /etc/asterisk/asterisk.conf

Remove "(!)" from line 1:

* [directories](!)

Install and configure FreePBX:

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

Reboot to be safe.

Navigate to the IP of your FreePBX instance and create a username and password:

Screenshot_2

The installation is now complete. I may attempt to automate this via Ansible/Chef for future deployments.

Show Comments

Get the latest posts delivered right to your inbox.