Experimenting with Asterisk 13 and FreePBX 13

Introduction

Do It Yourself an IPPBX, an experiment with Asterisk 13 and FreePBX 13 on CentOS 6.

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

Linux CentOS Minimal

Linux server installation:

  • You may use VirtualBox or any other virtualization software, or a real server
  • You need fast Internet connection, we will be downloading lots of stuffs
  • Install CentOS 6.7 minimal version, get the minimal version of CentOS 6.7 installer ISO here
  • Configure the network so that the server will have access to the Internet
  • Access the server using SSH, work from outside
  • You will need to login as root during installation

Please note that you can always use full version of CentOS, the same installation steps in this article will still work.

Suggestion on partition layout:

  • 4GB for /
  • 1GB for swap
  • the rest of available space for /var

Update CentOS:

[code lang=”text”]
yum update
[/code]

Install basic system config tools:

[code lang=”text”]
yum install system-config-firewall system-config-firewall-tui system-config-network system-config-network-tui
[/code]

Continue with rebooting the server:

[code lang=”text”]
reboot
[/code]

Please note that you must reboot the server to load the new updated kernel.

Development Packages

Install development packages:

[code lang=”text”]
yum install wget perl subversion gcc gcc-c++ make kernel-devel ncurses-devel newt-devel mysql-devel openssl-devel zlib-devel libxml2-devel curl-devel speex-devel unixODBC-devel libtool-ltdl-devel sqlite-devel libuuid-devel
[/code]

Please 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:

[code lang=”text”]
yum install httpd mysql-server mysql php php-mbstring php-mysql php-gd php-cli php-pear php-posix php-xml
[/code]

Start them now:

[code lang=”text”]
/etc/init.d/httpd start
/etc/init.d/mysqld start
[/code]

Set httpd and mysqld to run automatically on boot:

[code lang=”text”]
chkconfig httpd on
chkconfig mysqld on
[/code]

Configure Web Server

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

[code lang=”text”]
useradd asterisk
chown asterisk.asterisk -R /var/www/html /var/lib/php
[/code]

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

Edit /etc/httpd/conf/httpd.conf and change these optios:

  • User and Group setting, go to line 242-243 and change User apache to User asterisk and Group apache to Group asterisk
  • Allow access to .htaccess file, go to line 338 change AllowOverride None to AllowOverride All

[code lang=”text”]
vi /etc/httpd/conf/httpd.conf
[/code]

Please note that line numbers above are accurate at the time this article is written and no modification had been done to httpd.conf previously.

Make sure the web server run as user asterisk:

[code lang=”text”]
/etc/init.d/httpd restart
ps aux | grep httpd
[/code]

Configure Database Server

Set root password for MySQL database server, in this example we will use simple password password:

[code lang=”text”]
mysqladmin -uroot -p password 'password'
[/code]

Please note that the initial password for MySQL server is empty, just press ENTER.

Server Init

Follow all instructions to initialize your server.

Disable Firewall

Disable firewall from system config tool:

[code lang=”text”]
system-config-firewall
[/code]

Please note that you can enable the firewall again later after successful installation and several test calls.

Disable SELINUX

Edit /etc/sysconfig/selinux and change SELINUX=enforcing to SELINUX=disabled:

[code lang=”text”]
vi /etc/sysconfig/selinux
[/code]

Reboot the server to actually disable SELinux:

[code lang=”text”]
reboot
[/code]

Once the server up and running again check whether the SELinux is disabled:

[code lang=”text”]
sestatus
[/code]

Please note that the SELinux status must be disabled.

Part 2: Install Asterisk 13

Download Source Codes

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

[code lang=”text”]
mkdir -p /root/src
cd ~/src
[/code]

Get the latest Asterisk, current release is Asterisk 13.7.2:

[code lang=”text”]
wget -c http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13.7.2.tar.gz
[/code]

Please note that the above wget command and all wget commands below are single line only. You must make sure that the correct package will be downloaded to /root/src.

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

[code lang=”text”]
wget -c http://downloads.asterisk.org/pub/telephony/libpri/releases/libpri-1.4.15.tar.gz
[/code]

Get the latest Asterisk hardware drivers, current release is dahdi 2.11.0:

[code lang=”text”]
wget -c http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-2.11.0+2.11.0.tar.gz
[/code]

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

[code lang=”text”]
wget -c http://srtp.sourceforge.net/srtp-1.4.2.tgz
[/code]

Get JSON library for C:

[code lang=”text”]
wget -c http://www.digip.org/jansson/releases/jansson-2.7.tar.gz
[/code]

Get PJSIP:

[code lang=”text”]
wget -c http://www.pjsip.org/release/2.4.5/pjproject-2.4.5.tar.bz2
[/code]

Compile and Install PJSIP

Install PJSIP:

[code lang=”text”]
cd ~/src
tar -jxf pjproject-2.4.5.tar.bz2
cd pjproject-2.4.5
[/code]

On CentOS x86_64 version you must add --libdir=/usr/lib64 but on CentOS i386 (32 bit) version you must remove it.

Below command is to compile and install PJSIP on CentOS x86_64 version:

[code lang=”text”]
./configure CFLAGS='-O2 -DNDEBUG -DPJ_HAS_IPV6=1' –prefix=/usr –libdir=/usr/lib64 –enable-shared –disable-sound –disable-resample –disable-video –disable-opencore-amr
[/code]

If you are using CentOS i386 version then use this instead:

[code lang=”text”]
./configure CFLAGS='-O2 -DNDEBUG -DPJ_HAS_IPV6=1' –prefix=/usr –enable-shared –disable-sound –disable-resample –disable-video –disable-opencore-amr
[/code]

Continue to compile and install PJSIP:

[code lang=”text”]
make dep
make
make install
ldconfig
cd ../
[/code]

Compile and Install JSON Library

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

[code lang=”text”]
cd ~/src
tar -zxf jansson-2.7.tar.gz
cd jansson-2.7
./configure –prefix=/usr
make clean
make
make install
ldconfig
cd ../
[/code]

Compile and Install SRTP

Install Secure RTP library:

[code lang=”text”]
cd ~/src
tar -zxf srtp-1.4.2.tgz
cd srtp
./configure CFLAGS=-fPIC
make
make runtest
make install
ldconfig
cd ../
[/code]

Compile and Install DAHDI

Install Asterisk hardware drivers DAHDI:

[code lang=”text”]
cd ~/src
tar -zxf dahdi-linux-complete-2.11.0+2.11.0.tar.gz
cd dahdi-linux-complete-2.11.0+2.11.0
make all
make install
make config
cd ../
[/code]

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

Compile and Install libpri

Install PRI library:

[code lang=”text”]
cd ~/src
tar -zxf libpri-1.4.15.tar.gz
cd libpri-1.4.15
make
make install
ldconfig
cd ../
[/code]

Compile and Install Asterisk

Start to install Asterisk 13:

[code lang=”text”]
cd ~/src
tar -zxf asterisk-13.7.2.tar.gz
cd asterisk-13.7.2
[/code]

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

[code lang=”text”]
./contrib/scripts/get_mp3_source.sh
[/code]

Continue to select Asterisk modules:

[code lang=”text”]
./configure
make menuselect
[/code]

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 sound files and music on hold files are essential, but the selection type can be minimized into just EN WAV, GSM and G729.

Continue to compile and install Asterisk:

[code lang=”text”]
make
make install
[/code]

This is important, run ldconfig after make install:

[code lang=”text”]
ldconfig
[/code]

Continue to install sample configuration:

[code lang=”text”]
make samples
cd ../
[/code]

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:

[code lang=”text”]
asterisk -v
[/code]

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

Get FreePBX 13:

[code lang=”text”]
wget -c http://mirror.freepbx.org/modules/packages/freepbx/freepbx-13.0-latest.tgz
[/code]

Preparation

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

[code lang=”text”]
yum install sox
[/code]

Start to install FreePBX 13:

[code lang=”text”]
cd ~/src
tar -zxf freepbx-13.0-latest.tgz
cd freepbx
[/code]

Asterisk must be running during FreePBX 13 installation and 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:

[code lang=”text”]
vi /etc/asterisk/asterisk.conf
[/code]

Prepare to restart Asterisk and set Asterisk file permission:

[code lang=”text”]
mkdir -p /var/run/asterisk /etc/dahdi
touch /etc/modprobe.d/dahdi.conf
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
[/code]

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

[code lang=”text”]
./start_asterisk restart
[/code]

Test if the Asterisk is running:

[code lang=”text”]
ps aux | grep asterisk
asterisk -rx "core show uptime"
[/code]

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.

The database username is root and the database password is password.

Continue to install FreePBX:

[code lang=”text”]
./install
[/code]

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

[code lang=”text”]
fwconsole restart
[/code]

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, insert once:

[code lang=”text”]
echo "/usr/sbin/fwconsole start" >> /etc/rc.local
[/code]

Reboot the server:

[code lang=”text”]
reboot
[/code]

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:

  1. Open browser and browse the server’s IP address to login to FreePBX
  2. Create the admin username and password for FreePBX
  3. Login as admin user on FreePBX Administration
  4. 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:

  1. Visit Module Admin menu from the Admin tab
  2. Hit the Check Online button
  3. Click the Upgrade all button followed by Process button
  4. Click Confirm button to continue
  5. Hit Apply Config to implement changes

IPPBX installation finished.

Author

This howto is written by Anton Raharja.