Installing Asterisk + FreePBX

Today I will install Asterisk on Ubuntu Server 14.04 LTS and FreePBX 12 as a management interface.

So, switch directly to the root user:

sudo -i

Let’s check if there are updates for the system and install them:

apt-get update
apt-get upgrade

Install the necessary components:

apt-get install build-essential linux-headers-`uname -r` apache2 mysql-server mysql-client bison flex php5 php5-curl php5-cli php5-mysql php-pear php-db php5-gd curl sox libncurses5-dev libssl-dev libmysqlclient-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git subversion unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev libspandsp-dev libiksemel-dev libiksemel-utils libiksemel3

Restart the system:


Again, switch to the root user and install PearDB (the latest version can be viewed on the site

sudo -i
pear uninstall db
pear channel-update
pear install -Z db-1.7.14
pear list

You can update everything with the command:

pear upgrade-all

We compile and install Lame (this mp3 codec, it can also be installed automatically using the sudo apt-get install lame command):

cd /usr/src
tar zxvf lame-3.99.5.tar.gz
cd lame-3.99.5
make install

We compile and install DAHDI (the driver for the boards, it can also be installed automatically using the sudo apt-get install dahdi command):

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

We will compile and install LibPRI (the necessary library can also be installed via apt-get install libpri1.4):

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

We compile and install PJSIP (required library):

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

We will compile and install jansson:

cd /usr/src
git clone
cd jansson
autoreconf -i
make install

Let’s see what new version of Asterisk is on the official website, I took the last asterisk-13, compiled and installed it:

cd /usr/src
tar xvfz asterisk-13-current.tar.gz
cd asterisk-*
make menuselect

To support mp3, we’ll include the module ‘format_mp3’, note also that it is connected with mysql, in Core Sound Packages we note the support of Russian files, in Extra Sound Packages we will select additional sound files and choose “Save & Exit”.

We continue the installation:

make install
make config

Let’s see the new version of FreePBX on the official site and download it:

cd /usr/src
tar zxvf freepbx-*.tgz
cd /usr/src/freepbx

Create an Asterisk user and set the 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

Let’s change some settings in the Apache2 configuration file:

sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/apache2/php.ini
sed -ie 's/\;date\.timezone\ \=/date\.timezone\ \=\ "Europe\/Kiev"/g' /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

Create MySQL databases:

mysqladmin -u root -p create asterisk
mysqladmin -u root -p create asteriskcdrdb

Create a user and password for accessing MySQL databases:

mysql -u root -p -e "GRANT ALL PRIVILEGES ON asterisk.* TO asterisk@localhost IDENTIFIED BY 'PASSWORD';"
mysql -u root -p -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asterisk@localhost IDENTIFIED BY 'PASSWORD';"
mysql -u root -p -e "flush privileges;"

Run Asterisk and install FreePBX:

cd /usr/src/freepbx
./start_asterisk start
./install_amp --installdb --username=asterisk --password=ПАРОЛЬ

For FreePBX, you need to activate the mod_rewrite module in apache2:

a2enmod rewrite
service apache2 restart

Connect to the Asterisk console with the command:

asterisk -vvr

In the browser typing IP server should open the panel FreePBX.

I have a security notification in the FreePBX panel, so check the permissions on the files and restart the amportal:

amportal chown
amportal a ma refreshsignatures
amportal a reload

Also it is desirable to update the versions of modules in the admin menu – module admin.

The owner of http files should be asterisk, if suddenly the rights are violated, you can return them with the command:

chown -R asterisk:asterisk /var/www/html/

This completes the installation, followed by configuration, but this is already in another article.

Leave a Reply