Asterisk 13, FreePBX 13 on Ubuntu 16.04.2 ARM Devices Initial System Setup I assume you already have Ubuntu 16.04.2 rootfs for your ARM v7 Device. Therefore, boot your device and open up a command prompt. NOTE: Entire install process must be run as 'root', and failure to do so will cause unexpected problems.
Configure your root password # sudo passwd root
Switch to the Root User # sudo -i
Update Your System # apt-get update && sudo apt-get upgrade -y
Install Required Dependencies We have to use PHP5 for compatibility with FreePBX 13. Therfore, as the PHP5 is not available for Xenial anymore, we need to manually add the repository to be able to install PHP5.x # # # #
dpkg -l | grep php| awk '{print $2}' |tr "\n" " " add-apt-repository ppa:ondrej/php apt-get install software-properties-common sudo apt-get update
Then we install the required applications: # apt-get install -y build-essential openssh-server apache2 mysql-server mysql-client bison flex php5.6 php5.6-curl php5.6-cli php5.6-mysql php-pear php5.6-gd php5.6-xml php5.6-mbstring curl sox libncurses5-dev libssl-dev libmysqlclient-dev mpg123 libxml2dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev libspandsp-dev
On top of above, we also need to install libmyodbc. To be in Xenial, libmysqlclient20 is available, however it’s requires to have libmysqlclient18 but this package is not available in Xenial repository. Therfore, we get the deb package and install in manually: # wget http://launchpadlibrarian.net/212191758/libmysqlclient18_5.6.250ubuntu1_armhf.deb # dpkg -i /root/libmysqlclient18_5.6.25-0ubuntu1_armhf.deb
© Copyright ELAR Systems 2015-2017 http://www.elar-systems.com(.au)
We also have to install “libmyodbc” for future access to MySQL via ODBC connection. # wget http://launchpadlibrarian.net/141005805/libmyodbc_5.1.10-3_armhf.deb # dpkg -i /root/libmyodbc_5.1.10-3_armhf.deb
Now we install should be able to install ‘libmysqlclient20’: # apt-get install libmysqlclient20
To be sure all applications installed: # apt-get -f install
We should have these two files available in folder addressed bellow; we need them later when we setup ODBC: # ls /usr/lib/arm-linux-gnueabihf/odbc/ libmyodbc.so libodbcmyS.so
Reboot Device # reboot
After the Reboot Ensure that you re-run 'sudo -i', or log in as the root user. As mentioned above, the entire install process must be run as 'root', and failure to do so will cause unexpected problems.
Switch PHP Version # a2dismod php7.0 ; a2enmod php5.6 ; service apache2 restart # update-alternatives --set php /usr/bin/php5.6 # service apache2 restart
Ensure mod_rewrite is enabled in apache This is used to avoid potential attacks, and needs to be enabled. # a2enmod rewrite # service apache2 restart
Install Legacy pear requirements # pear install Console_Getopt
© Copyright ELAR Systems 2015-2017 http://www.elar-systems.com(.au)
Install and Configure Asterisk Download Asterisk source files # # # #
cd /usr/src wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz wget -O jansson.tar.gz https://github.com/akheron/jansson/archive/v2.10.tar.gz wget http://www.pjsip.org/release/2.6/pjproject-2.6.tar.bz2
What about DAHDI ?! We probably will not have any physical PSTN hardware attached to ARM devices (For example, a T1 or E1 card, or a USB device); therefore, you don't need to install DAHDI.
Compile and install pjproject # cd /usr/src # tar -xjvf pjproject-2.6.tar.bz2 # rm -f pjproject-2.6.tar.bz2 # cd pjproject-2.6 # CFLAGS='-DPJ_HAS_IPV6=1' ./configure --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr --disable-libwebrtc # make dep # make # make install
Compile and Install jansson # # # # # # # #
cd /usr/src tar vxfz jansson.tar.gz rm -f jansson.tar.gz cd jansson-* autoreconf -i ./configure make make install
Compile and install Asterisk # # # # # # # #
cd /usr/src tar xvfz asterisk-13-current.tar.gz rm -f asterisk-13-current.tar.gz cd asterisk-* contrib/scripts/install_prereq install ./configure contrib/scripts/get_mp3_source.sh make menuselect
You will be prompted at the point to pick which modules to build.
© Copyright ELAR Systems 2015-2017 http://www.elar-systems.com(.au)
Most of them will already be enabled, but if you want to have MP3 support (eg, for Music on Hold), you need to manually turn on 'format_mp3' on the first page.
After selecting 'Save & Exit' you can then continue: # # # # #
make make install make config ldconfig update-rc.d -f asterisk remove
Install Asterisk Sound files The 'make install' above installs a standard low-quality base sound file by default. This is suitable if you are on a small, underpowered system (such as a Rasberry Pi), but on a larger system you should install higher quality soundfiles. Note that this installs the (8khz) 'wav' soundfiles and G722 (High Definition 'Wideband') audio. # # cd /var/lib/asterisk/sounds # wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-wavcurrent.tar.gz # wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wavcurrent.tar.gz # tar xvf asterisk-core-sounds-en-wav-current.tar.gz # rm -f asterisk-core-sounds-en-wav-current.tar.gz
© Copyright ELAR Systems 2015-2017 http://www.elar-systems.com(.au)
# tar xfz asterisk-extra-sounds-en-wav-current.tar.gz rm -f asterisk-extra-sounds-en-wav-current.tar.gz Wideband Audio download # wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-g722current.tar.gz # wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722current.tar.gz # tar xfz asterisk-extra-sounds-en-g722-current.tar.gz # rm -f asterisk-extra-sounds-en-g722-current.tar.gz # tar xfz asterisk-core-sounds-en-g722-current.tar.gz # rm -f asterisk-core-sounds-en-g722-current.tar.gz
Install and Configure FreePBX
Create the Asterisk user and set base file permissions: # # # # # #
useradd -m asterisk 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
A few small modifications to Apache # # # # #
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/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 service apache2 restart
Configure ODBC Edit ‘/etc/odbcinst.ini’ and add the following. Note that this command assumes you are installing to a new machine, and that the file is empty. If this is not a freshly installed machine, please manually verify the contents of the file, rather than just copying and pasting the lines below. The 'EOF' does no go in the file, it simply signals to the 'cat' command that you have finished pasting. # cat >> /etc/odbcinst.ini << EOF [MySQL] Description = ODBC for MySQL Driver = /usr/lib/arm-linux-gnueabihf/odbc/libmyodbc.so Setup = /usr/lib/arm-linux-gnueabihf/odbc/libodbcmyS.so FileUsage = 1 EOF
You may need to verify these paths, you can use the command ‘find / -name libmyodbc.so’ and ‘find / -name libodbcmyS.so’ to verify the location.
© Copyright ELAR Systems 2015-2017 http://www.elar-systems.com(.au)
Edit or create ‘/etc/odbc.ini’ and add the following section. Note that, again, this command assumes you are installing to a new machine, and the file is empty. Please manually verify the contents of the files if this is not the case.
# cat >> /etc/odbc.ini << EOF [MySQL-asteriskcdrdb] Description=MySQL connection to 'asteriskcdrdb' database driver=MySQL server=localhost database=asteriskcdrdb Port=3306 Socket=/var/run/mysqld/mysqld.sock option=3 EOF
Download and install FreePBX # # # # # # #
cd /usr/src wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-13.0-latest.tgz tar vxfz freepbx-13.0-latest.tgz rm -f freepbx-13.0-latest.tgz cd freepbx ./start_asterisk start ./install –n
NOTE: At the time of writing this document, The FreePBX installation script does not created a required table for CDR in asteriskcdrdb called ‘cdr’. Therfore, the “cdr.sql” file which should contains proper syntax to create the required table in MySQL database needs to be loaded to MySQL: cdr.sql # -- Host: localhost Database: asteriskcdrdb -- -----------------------------------------------------/*!40101 /*!40101 /*!40101 /*!40101 /*!40103 /*!40103 /*!40014 /*!40014 /*!40101 /*!40111
SET SET SET SET SET SET SET SET SET SET
@OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; NAMES utf8 */; @OLD_TIME_ZONE=@@TIME_ZONE */; TIME_ZONE='+00:00' */; @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
use asteriskcdrdb; -- Table structure for table `cdr` -- ------------------------------------------------------
© Copyright ELAR Systems 2015-2017 http://www.elar-systems.com(.au)
DROP TABLE IF EXISTS `cdr`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cdr` ( `calldate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `clid` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `src` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `dst` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `dcontext` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `channel` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `dstchannel` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `lastapp` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `lastdata` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `duration` int(11) NOT NULL DEFAULT '0', `billsec` int(11) NOT NULL DEFAULT '0', `disposition` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `amaflags` int(11) NOT NULL DEFAULT '0', `accountcode` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `uniqueid` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `userfield` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `did` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `recordingfile` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `cnum` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `cnam` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `outbound_cnum` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `outbound_cnam` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `dst_cnam` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', KEY `calldate` (`calldate`), KEY `dst` (`dst`), KEY `accountcode` (`accountcode`), KEY `uniqueid` (`uniqueid`), KEY `did` (`did`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; *!40101 SET character_set_client = @saved_cs_client */;
To import it: # mysql < /path/to/cdr.sql
Uninstall FreePBX In case something happened that you need to reinstall FreePBX from scratch, just uninstall FreePBX follow the below steps and reinstall it again: Access the MySQL command line interface by typing: # mysql -u root
Drop the tables from MySQL. Instruct MySQL to drop the ‘asteriskdb’ and ‘asteriskcdrdb’ databases by typing: mysql> DROP DATABASE asterisk;
© Copyright ELAR Systems 2015-2017 http://www.elar-systems.com(.au)
mysql> DROP DATABASE asteriskcdrdb; mysql> exit;
Delete the FreePBX related files by issuing the following commands: # # # # # # # #
rm rm rm rm rm rm rm rm
/usr/sbin/amportal -rf /var/lib/asterisk/bin/* -rf /var/www/html/* /etc/amportal.conf /etc/asterisk/amportal.conf /etc/freepbx.conf /etc/asterisk/freepbx.conf -f /etc/asterisk/*.conf
Login to FreePBX Admin Panel You can now start using FreePBX. Open up your web browser and connect to the IP address or hostname of your new FreePBX server. You will see the Admin setup page, which is where you set your 'admin' account password, and configure an email address to receive update notifications.
© Copyright ELAR Systems 2015-2017 http://www.elar-systems.com(.au)