Asterisk 13 and FreePBX 13 on Ubuntu 14.04

Introduction

Yet another Do It Yourself an IPPBX, this time using Asterisk 13 and FreePBX 13 on Ubuntu Server 14.04. If you preferred to use CentOS you may visit another article I wrote about the same topic on CentOS minimal instead.

This article is divided into three parts:

  • Part 1: Prepare The Server
  • Part 2: Install Asterisk 13
  • Part 3: Install FreePBX 13

The goal is to get the PC provides Private Branch eXchange services, a phone system, using Free and Open Source Software.

Part 1: Prepare The Server

Ubuntu Server 14.04

Update Ubuntu:

sudo apt-get -y update
sudo apt-get -y upgrade

Reboot the server, just to make sure the new Kernel will be loaded:

sudo reboot

Please note that the reboot is essential, new Kernel must be loaded prior to compiling and installing DAHDI, below.

Development Packages

Install development packages:

sudo apt-get -y install wget subversion build-essential libncurses5-dev libnewt-dev libmysqlclient-dev libssl-dev zlib1g-dev libxml2-dev libcurl4-openssl-dev libspeex-dev unixODBC-dev libltdl-dev libsqlite3-dev uuid-dev

Please note that above command is in single line.

Please also note that you need to make sure that above packages are installed properly, you can do that by running the above command again.

Web and Database Server

Install Web and Database Server

Install Apache2 web server and MySQL database server:

sudo apt-get -y install apache2 mysql-server mysql-client php5 php5-mysql php5-gd php5-curl php5-cli php-pear

Please note that you will be asked a password for root user of MySQL server. In this article the root password of MySQL server is password.

Start them now:

sudo /etc/init.d/apache2 start
sudo /etc/init.d/mysql start

Make sure both Apache2 and MySQL start on boot:

sudo update-rc.d apache2 defaults
sudo update-rc.d mysql defaults

Configure Web Server

Add Linux user for Asterisk and web server followed by changing files ownership:

sudo useradd asterisk
sudo chown asterisk.asterisk -R /var/www/html /var/lib/php5

Please note that the Linux user asterisk will be running both Asterisk and web server daemons.

Edit /etc/apache2/envvars and change the user and group that is running Apache2:

  • Around line 16, change APACHE_RUN_USER from www-data to asterisk
  • On the next line, change APACHE_RUN_GROUP from www-data to asterisk
sudo vi /etc/apache2/envvars

Edit /etc/apache2/apache2.conf and change AllowOverride option so that Apache2 will read .htaccess:

  • Around line 166, inside the /var/www directory option block, change AllowOverride None to AllowOverride All
sudo vi /etc/apache2/apache2.conf

Restart Apache2 and make sure its running as user asterisk:

sudo /etc/init.d/apache2 restart
ps aux | grep apache2

Part 2: Install Asterisk 13

Download Source Codes

Prepare sources directory in ~/src, all required software source codes will be put in that directory:

mkdir -p ~/src
cd ~/src

Just in case you don’t know, ~/src means if your current active Linux user is support then ~/src is equal to /home/support/src.

Get the latest Asterisk, current release is Asterisk 13.7.2:

wget -c http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13.7.2.tar.gz

Please note that the above wget command and all wget commands below are single line only. You must make sure that all packages are downloaded in ~/src.

Get the latest PRI library, current release is libpri 1.4.15:

wget -c http://downloads.asterisk.org/pub/telephony/libpri/releases/libpri-1.4.15.tar.gz

Get the Asterisk hardware drivers, current release is dahdi 2.11.0, but for Ubuntu Server 14.04 we will use 2.10.2, the 2.11.0 will not compiled cleanly:

wget -c http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-2.10.2+2.10.2.tar.gz

Get Secure RTP library, we will be using SRTP 1.4.2:

wget -c http://srtp.sourceforge.net/srtp-1.4.2.tgz

Get JSON library for C:

wget -c http://www.digip.org/jansson/releases/jansson-2.7.tar.gz

Get PJSIP:

wget -c http://www.pjsip.org/release/2.4.5/pjproject-2.4.5.tar.bz2

Compile and Install PJSIP

Compile and install PJSIP:

cd ~/src
tar -jxf pjproject-2.4.5.tar.bz2
cd pjproject-2.4.5
./configure CFLAGS='-O2 -DNDEBUG -DPJ_HAS_IPV6=1' --prefix=/usr --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr
make dep
make
sudo make install
sudo ldconfig
cd ../

Compile and Install JSON Library

Jansson is a C library for encoding, decoding and manipulating JSON data. Compile and install this library:

cd ~/src
tar -zxf jansson-2.7.tar.gz
cd jansson-2.7
./configure --prefix=/usr
make clean
make
sudo make install
sudo ldconfig
cd ../

Compile and Install SRTP

Compile and install Secure RTP library:

cd ~/src
tar -zxf srtp-1.4.2.tgz
cd srtp
./configure CFLAGS=-fPIC
make
make runtest
sudo make install
sudo ldconfig
cd ../

Compile and Install DAHDI

Compile and install Asterisk hardware drivers DAHDI:

cd ~/src
tar -zxf dahdi-linux-complete-2.10.2+2.10.2.tar.gz
cd dahdi-linux-complete-2.10.2+2.10.2
make all
sudo make install
sudo make config
cd ../

Please note that DAHDI must be installed before libpri and Asterisk.

Compile and Install libpri

Compile and install PRI library:

cd ~/src
tar -zxf libpri-1.4.15.tar.gz
cd libpri-1.4.15
make
sudo make install
sudo ldconfig
cd ../

Compile and Install Asterisk

Start to install Asterisk 13:

cd ~/src
tar -zxf asterisk-13.7.2.tar.gz
cd asterisk-13.7.2

Get mp3 source library, Asterisk package does not provide it:

./contrib/scripts/get_mp3_source.sh

Continue to select Asterisk modules:

./configure
make menuselect

Inside make menuselect you may choose which packages you want to install or remove.

Here is the recommended options:

  • Add-ons tab select chan_ooh323, format_mp3 and cdr_mysql
  • Applications tab select app_meetme
  • Channel Drivers tab make sure to select chan_pjsip
  • Core Sound Packages tab select EN WAV, ULAW, GSM, G729
  • Music On Hold File Packages tab select EN WAV, ULAW, GSM, G729
  • Extras Sound Packages tab select EN WAV, ULAW, GSM, G729

Please note that selection can be made by pressing Enter until the checkbox filled.

Continue to compile and install Asterisk:

make
sudo make install

This is important, run ldconfig after make install:

sudo ldconfig

Continue to install sample configuration:

sudo make samples
cd ../

Test the installed Asterisk by running it and then hit Ctrl+C to stop it once the label Asterisk Ready at the end of the command is shown:

sudo asterisk -v

Please note that we don’t need to install Asterisk init script as we will use the FreePBX start and stop init script later.

Part 3: Install FreePBX 13

Download Source Codes

Get FreePBX 13:

cd ~/src
wget -c http://mirror.freepbx.org/modules/packages/freepbx/freepbx-13.0-latest.tgz

Preparation

Install sox for audio transcoding that will be used by FreePBX 13:

sudo apt-get install sox

Extract the FreePBX 13 package:

cd ~/src
tar -zxf freepbx-13.0-latest.tgz
cd freepbx

An adjustment need to be done on Asterisk config file asterisk.conf. Apparently the mark (!) on the end of the first line of /etc/asterisk/asterisk.conf will fail the FreePBX 13 installer script, therefore it must be removed.

Edit /etc/asterisk/asterisk.conf, change [directories](!) to just [directories] and then save the file:

sudo vi /etc/asterisk/asterisk.conf

Prepare to start Asterisk and set Asterisk file permission:

sudo mkdir -p /var/run/asterisk /etc/dahdi
sudo touch /etc/modprobe.d/dahdi.conf

Set files ownership:

sudo chown asterisk.asterisk -R /usr/lib/asterisk /etc/asterisk /var/lib/asterisk /var/log/asterisk /var/spool/asterisk /var/run/asterisk /etc/dahdi /etc/modprobe.d/dahdi.conf

Please note that above command is single line only.

Continue to run Asterisk, FreePBX provides a script to run the Asterisk:

cd ~/src/freepbx
sudo ./start_asterisk restart

Please note that Asterisk must be running during FreePBX 13 installation.

Test if the Asterisk is running:

ps aux | grep asterisk
sudo asterisk -rx "core show uptime"

Remove (or rename) existing index.html from /var/www/html:

sudo mv /var/www/html/index.html /var/www/html/index.html.orig

FreePBX Installation

Please pay attention to details, you will be asked several important questions and you must answer them correctly. Most importantly the Database username and Database password questions must be answered correctly, other questions you may left them as default.

In this article the database username is root and the database password is password.

Continue to install FreePBX:

cd ~/src/freepbx
sudo ./install

Try to restart FreePBX, including the Asterisk, using fwconsole:

sudo fwconsole restart

After installation process the server must be configured to run fwconsole start on boot. Insert /usr/sbin/fwconsole start at the bottom of /etc/rc.local before the exit 0 command.

Edit /etc/rc.local and insert once (before exit 0):

sudo vi /etc/rc.local

Reboot the server:

sudo reboot

Please note that the server reboot is required before accessing FreePBX from browser.

FreePBX Setup

Follow below steps to initialize FreePBX for the first time:

  • Open browser and browse the server’s IP address to start FreePBX setup
  • Create the admin username and password for FreePBX
  • Login as admin user on FreePBX Administration
  • Hit the red Apply Config button on top.

At this point the IPPBX is ready, but before proceeding with other configuration you should consider to update the FreePBX.

Follow below steps to update FreePBX for the first time:

  • Visit Module Admin menu from the Admin tab
  • Hit the Check Online button
  • Click the Upgrade all button followed by Process button
  • Click Confirm button to continue
  • Hit Apply Config to implement changes

IPPBX installation finished.

Author

This howto is written by Anton Raharja.

Advertisements

10 thoughts on “Asterisk 13 and FreePBX 13 on Ubuntu 14.04

  1. In the section entitled “Compile and Install PJSIP” on the “./configure” command I get an error of “aconfigure: error: in ‘home/user/src/pjproject-2.4.5’ aconfigure: error: C compiler cannot create executables” I am running a fresh install of Ubuntu 14.04.5 and have followed all of the instructions prior to this step. I have tried re-booting, re-downloading and extracting the pjproject file. still the same error. Can you please help?

    Like

      1. I have tried both 32 and 64 bit. I also tried updating the gcc from 4.8 to 6.1.1 in the 32 bit version. Still same error.

        Like

      2. Even though pjsip compiles without options included in the “./configure” command, when i enter the “make” command on Asterisk, it gives several errors related to pjsp. I am about ready to give up on this whole mess.

        Like

    1. Found what was causing the error in the original “./configure” command for pjsip. The O2 needs to be a capatal letter O not a zero. The mistake was mine in reading the command wrong. Sorry to waste your time.

      Like

  2. Dear Sir. Really nice tutorial but i am having an issue. It says that cannot connect to asterisk. In /rtc/rc.local i have the /usr/sbin/fwconsole start without success. it only works if i manually type fwconsole start. i have even edited the /etc/rc.local to have only fwconsole start, without any success.
    any ideas, please?

    Like

Comments are closed.