How to Install Asterisk 15 on Ubuntu 18.04 from Source

In this article, I will explain how to install Asterisk 15 on Ubuntu 18.04 from source. The new version, the Asterisk 15, is bringing us a lot of new functionality. Top of the list, new SIP stack, called pjsip is now part of the install, it is bundled and there is no need to install it separately like in previous releases. For full list what is new you can see Asterisk site.

Obtaining sources of Asterisk 15

For successful installation of Asterisk 15 you would need to go as root.

sudo su

We are going to download sources in /usr/src/ so lets change directory to there

cd /usr/src/

Next, we can download the latest version of Asterisk 15.

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-15-current.tar.gz

Then we need to unpack it.

tar zxvf asterisk-15-current.tar.gz

Obviously, we need to use cd command to change directory, but we need to have one thing in mind. Asterisk minor versions come out quite often and version 15.3.0 which was latest at the time of writing will very soon be outdated. So the following command won't work in its verbatim state:

cd asterisk-15.3.0/

We will need to change it to the current version. Or simply use asterisk like this, (no pun intended)

cd asterisk-15*/

Installing Dependencies

Now we need to install dependencies

apt-get install build-essential wget libssl-dev libncurses5-dev libnewt-dev libxml2-dev linux-headers-$(uname -r) libsqlite3-dev uuid-dev git subversion

Mp3 from source is also needed

contrib/scripts/get_mp3_source.sh

And last dependencies are added by a script

contrib/scripts/install_prereq install

Compilation and set up

We can commence compilation with the following command:

./configure && make menuselect && make && make install

Somewhere in the middle, ncurses environment will show up and give you a choice of components. You can accept defaults.

After compilation is done, you need sample configs.

make samples

Also, systemd unit file needs to be installed and you do it with this command

make config

Linking shared libraries is done with this command

ldconfig

For better security, we want Asterisk to run as asterisk user in asterisk group. Let's add user and the group

groupadd asterisk
useradd -d /var/lib/asterisk -g asterisk asterisk

The user will have a custom home directory in /var/lib/asterisk

Next, we need to uncomment lines for AST group and user in /etc/default/asterisk. We will do it with sed command but doing it with nano or vi is also ok.

sed -i 's/#AST_USER="asterisk"/AST_USER="asterisk"/g' /etc/default/asterisk
sed -i 's/#AST_GROUP="asterisk"/AST_GROUP="asterisk"/g' /etc/default/asterisk

One more tweak is to uncomment runuser and rungroup lines in /etc/asterisk.conf

sed -i 's/;runuser = asterisk/runuser = asterisk/g' /etc/asterisk/asterisk.conf

sed -i 's/;rungroup = asterisk/rungroup = asterisk/g' /etc/asterisk/asterisk.conf

And lastly, we need to change owner of all relevant asterisk directories to user asterisk.

chown -R asterisk:asterisk /var/spool/asterisk /var/run/asterisk /etc/asterisk /var/{lib,log,spool}/asterisk /usr/lib/asterisk

Running the Asterisk

At last, we will start asterisk

asterisk -rvvv

And it will give us  output similar to following:

Asterisk 15.3.0, Copyright (C) 1999 - 2016, Digium, Inc. and others.
Created by Mark Spencer <[email protected]>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Running as user 'asterisk'
Running under group 'asterisk'
Connected to Asterisk 15.3.0 currently running on linoxide (pid = 1085)

Read also :

And that would be it, we have Asterisk up and running securely as asterisk user. From here you can write dial plans and have your extensions (client phones) connected. But that is a story for some future article. Thank you for reading, and if you have questions, please feel free to comment. Have a nice day.

 

Mihajlo Milenovic 12:05 am

About Mihajlo Milenovic

Miki is a long time GNU/Linux user, Free Software advocate and a freelance system administrator from Serbia. Got introduced to GNU/Linux in year 2003 on old AMD Duron computer, and since than always eager to learn new stuff about this system. From 2016 writes for Linoxide to share his experiences with wider audience

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.