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.


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


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


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 <>
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 articles. Thank you for reading, and if you have questions, please feel free to comment. Have a nice day.

11 Comments... add one

  1. Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)
    Getting this message when I enter 'asterisk -rvvv'. I've done all the steps given above in the article still I'm getting the 'unable to connect to remote asterisk' message in my terminal

  2. Great post. I'm trying to follow it, but when installing the dependencies, the subversion package isn't available. Any good replacement for it?
    Thanks in advance!

  3. I needed to setup Asterisk from source to make use of gvsip.
    It was pointed out to me that running "make samples" can open you up to some security vulnerabilities.
    However, if I do not run "make samples" then I have issues following the Freepbx install.

    I have a thread going on Freepbx forums:

    If anyone thinks they might no a solution to run asterisk as Non root, and not use the "make samples" line

  4. Can you also please post instructions on how to upgrade an existing system from Asterisk 13 to 14 or 15


  5. Hi, you have to edit the /etc/apt/sources.list file adding "universe" at the end of each line and then run sudo apt-get update.

  6. /usr/src/asterisk-16.0.1# asterisk -rvvvvv
    Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)

    /etc/init.d/asterisk start
    [....] Starting asterisk (via systemctl): asterisk.serviceJob for asterisk.service failed because a timeout was exceeded.
    See "systemctl status asterisk.service" and "journalctl -xe" for details.

    Can you help me with this?


Leave a Comment