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:

reboot

Again, switch to the root user and install PearDB (the latest version can be viewed on the site http://pear.php.net/package/DB/download):

sudo -i
pear uninstall db
pear channel-update pear.php.net
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
wget https://sourceforge.net/projects/lame/files/lame/3.99/lame-3.99.5.tar.gz
tar zxvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure
make
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
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
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
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz
tar xvfz libpri-current.tar.gz
cd /usr/src/libpri-*
make
make install

We compile and install PJSIP (required library):

cd /usr/src
wget http://www.pjsip.org/release/2.4.5/pjproject-2.4.5.tar.bz2
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
make install

We will compile and install jansson:

cd /usr/src
git clone https://github.com/akheron/jansson.git
cd jansson
autoreconf -i
./configure
make
make install

Let’s see what new version of Asterisk is on the official website http://downloads.asterisk.org/pub/telephony/asterisk/, I took the last asterisk-13, compiled and installed it:

cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar xvfz asterisk-13-current.tar.gz
cd asterisk-*
./configure
contrib/scripts/get_mp3_source.sh
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
make install
make config
ldconfig

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

cd /usr/src
wget http://mirror.freepbx.org/freepbx-12.0.43.tgz
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 comment

Leave a Reply