How to install Asterisk 17 on Ubuntu 20.04 | 18.04

To
You can download this article in PDF format via the link below to support us.

Download the guide in PDF format

turn off
To

To
To

Asterisk is a free and open source framework, by Sangoma Used to build communication applications for small companies and large use cases. Asterisk is a software-based solution that can transform your old computer into a communication server powered by an IP PBX system, VoIP gateway, conference server and other custom solutions. The solutions built by Asterisk can power call centers, operators and government agencies around the world.

In this blog post, we will introduce the process of installing Asterisk 17 on Ubuntu 20.04 | 18.04 server. At the time of writing, the latest version of Asterisk is 17. In addition, please note that this is not a long-term version and should not be used for production deployments that require Digium long-term support.

Some key points about asterisks are:

Install Asterisk 17 on Ubuntu 20.04 | 18.04

You will follow the steps in the next section to install Asterisk 17 on an Ubuntu 20.04 | 18.04 Linux system. Since Asterisk is created modularly, it is not difficult to add additional features after installation. This is easy to do.

Step 1: Update the Ubuntu system

We will start the installation by updating the APT package index and upgrading all packages installed on the system. I recommend that you perform this installation on a new system to avoid any problems when running the service.

sudo apt update
sudo apt -y upgrade

If the upgrade process is successful, you can restart the system.

sudo systemctl reboot

Step 2: Install build dependencies

After the system reboots, log in and install all the dependencies required to build Asterisk on the Ubuntu 20.04 | 18.04 Linux computer.

sudo apt update
sudo add-apt-repository universe
sudo apt -y install git curl wget libnewt-dev libssl-dev libncurses5-dev subversion  libsqlite3-dev build-essential libjansson-dev libxml2-dev  uuid-dev

If your internet connection is good, the installation will only take a few minutes.

Step 3: Download the compressed file of Asterisk 17

The latest version of Asterisk cannot be found in the official system repository. We must manually download the tarball and build the application from source code.

On Ubuntu 20.04, the version available in the APT repository is 16.

$ sudo apt policy asterisk
asterisk:
  Installed: (none)
  Candidate: 1:16.2.1~dfsg-2ubuntu1
  Version table:
     1:16.2.1~dfsg-2ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
        500 http://mirror.hetzner.de/ubuntu/packages focal/universe amd64 Packages

Use the wget command to download the archive file.

cd ~
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-17-current.tar.gz

Unzip the file with tar.

tar xvf asterisk-17-current.tar.gz

Run the following command to download the mp3 decoder library to the source code tree.

cd asterisk-17*/
contrib/scripts/get_mp3_source.sh

Expected command execution output:

A    addons/mp3
A    addons/mp3/MPGLIB_README
A    addons/mp3/common.c
A    addons/mp3/huffman.h
A    addons/mp3/tabinit.c
A    addons/mp3/Makefile
A    addons/mp3/README
A    addons/mp3/decode_i386.c
A    addons/mp3/dct64_i386.c
A    addons/mp3/MPGLIB_TODO
A    addons/mp3/mpg123.h
A    addons/mp3/layer3.c
A    addons/mp3/mpglib.h
A    addons/mp3/decode_ntom.c
A    addons/mp3/interface.c
Exported revision 202.

Make sure all dependencies are resolved:

sudo contrib/scripts/install_prereq install

You should receive a success message at the end:

#############################################
## install completed successfully
#############################################

Step 4: Build and install Asterisk 17 on Ubuntu 20.04 | 18.04

After installing the dependencies, you should be ready to build Asterisk 17 from the source code we downloaded.

Run over Configuration Script to satisfy build dependencies.

./configure

Success should have the following output:

.....
configure: creating ./config.status
config.status: creating makeopts
config.status: creating autoconfig.h
configure: Menuselect build configuration successfully completed

               .$$$$$$$$$$$$$$$=..
            .$7$7..          .7$$7:.
          .$$:.                 ,$7.7
        .$7.     7$$$$           .$$77
     ..$$.       $$$$$            .$$$7
    ..7$   .?.   $$$$$   .?.       7$$$.
   $.$.   .$$$7. $$$$7 .7$$$.      .$$$.
 .777.   .$$$$$$77$$$77$$$$$7.      $$$,
 $$$~      .7$$$$$$$$$$$$$7.       .$$$.
.$$7          .7$$$$$$$7:          ?$$$.
$$$          ?7$$$$$$$$$$I        .$$$7
$$$       .7$$$$$$$$$$$$$$$$      :$$$.
$$$       $$$$$$7$$$$$$$$$$$$    .$$$.
$$$        $$$   7$$$7  .$$$    .$$$.
$$$$             $$$$7         .$$$.
7$$$7            7$$$$        7$$$
 $$$$$                        $$$
  $$$$7.                       $$  (TM)
   $$$$$$$.           .7$$$$$$  $$
     $$$$$$$$$$$$7$$$$$$$$$.$$$$$$
       $$$$$$$$$$$$$$$$.

configure: Package configured for:
configure: OS type  : linux-gnu
configure: Host CPU : x86_64
configure: build-cpu:vendor:os: x86_64 : pc : linux-gnu :
configure: host-cpu:vendor:os: x86_64 : pc : linux-gnu :

Set the menu options by running the following command:

make menuselect

Use the arrow keys to navigate, then Input Key to select.

Select the plugin you want to enable.

Enable the Core sound module to be used.

How to install Asterisk 17 on Ubuntu 20.04 | 18.04

You can also add other MOH packages you want to use.

How to install Asterisk 17 on Ubuntu 20.04 | 18.04

Do the same for Extra Sound Packages.

How to install Asterisk 17 on Ubuntu 20.04 | 18.04

You can also browse other menus and select the options that suit your use case.

When finished, run the following command to build Asterisk 17 on Ubuntu 20.04 | 18.04.

make

This is my successful build output:

.....
TROLEnc.o ooh323cDriver.o -> chan_ooh323.so
   [CC] format_mp3.c -> format_mp3.o
   [CC] mp3/common.c -> mp3/common.o
   [CC] mp3/dct64_i386.c -> mp3/dct64_i386.o
   [CC] mp3/decode_ntom.c -> mp3/decode_ntom.o
   [CC] mp3/layer3.c -> mp3/layer3.o
   [CC] mp3/tabinit.c -> mp3/tabinit.o
   [CC] mp3/interface.c -> mp3/interface.o
   [LD] format_mp3.o mp3/common.o mp3/dct64_i386.o mp3/decode_ntom.o mp3/layer3.o mp3/tabinit.o mp3/interface.o -> format_mp3.so
   [CC] res_config_mysql.c -> res_config_mysql.o
   [LD] res_config_mysql.o -> res_config_mysql.so
Building Documentation For: third-party channels pbx apps codecs formats cdr cel bridges funcs tests main res addons
 +--------- Asterisk Build Complete ---------+
 + Asterisk has successfully been built, and +
 + can be installed by running:              +
 +                                           +
 +                make install               +
 +-------------------------------------------+

This is the command you want to install Asterisk 17 on Ubuntu 20.04:

sudo make install

Sample output:

....
make[1]: Entering directory '/home/jkmutai/asterisk-17.6.0/sounds'
make[1]: Leaving directory '/home/jkmutai/asterisk-17.6.0/sounds'
find rest-api -name "*.json" | while read x; do 
	/usr/bin/install -c -m 644 $x "/var/lib/asterisk/rest-api" ; 
done
 +---- Asterisk Installation Complete -------+
 +                                           +
 +    YOU MUST READ THE SECURITY DOCUMENT    +
 +                                           +
 + Asterisk has successfully been installed. +
 + If you would like to install the sample   +
 + configuration files (overwriting any      +
 + existing config files), run:              +
 +                                           +
 + For generic reference documentation:      +
 +    make samples                           +
 +                                           +
 + For a sample basic PBX:                   +
 +    make basic-pbx                         +
 +                                           +
 +                                           +
 +-----------------  or ---------------------+
 +                                           +
 + You can go ahead and install the asterisk +
 + program documentation now or later run:   +
 +                                           +
 +               make progdocs               +
 +                                           +
 + **Note** This requires that you have      +
 + doxygen installed on your local system    +
 +-------------------------------------------+

You can choose to install the document:

sudo make progdocs

Finally, install the configuration and examples.

sudo make samples
sudo make config
sudo ldconfig

Step 5: Start Asterisk service on Ubuntu 20.04 | 18.04

Create a separate user and group to run the Asterisk service, and assign the correct permissions:

sudo groupadd asterisk
sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk
sudo usermod -aG audio,dialout asterisk
sudo chown -R asterisk.asterisk /etc/asterisk
sudo chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
sudo chown -R asterisk.asterisk /usr/lib/asterisk

Set Asterisk default user to Asterisk:

$ sudo vim /etc/default/asterisk
AST_USER="asterisk"
AST_GROUP="asterisk"

$ sudo vim /etc/asterisk/asterisk.conf
runuser = asterisk ; The user to run as.
rungroup = asterisk ; The group to run as.

After making the changes, restart the Asterisk service:

sudo systemctl restart asterisk

Enable the star service to start at system startup:

sudo systemctl enable asterisk

Check the service status to see if it is running.

$ systemctl status asterisk
● asterisk.service - LSB: Asterisk PBX
     Loaded: loaded (/etc/init.d/asterisk; generated)
     Active: active (running) since Fri 2020-08-14 12:04:41 CEST; 9s ago
       Docs: man:systemd-sysv-generator(8)
      Tasks: 82 (limit: 4567)
     Memory: 44.6M
     CGroup: /system.slice/asterisk.service
             └─54142 /usr/sbin/asterisk -U asterisk -G asterisk

Verify that you can connect to the Asterisk command line interface.

$ sudo asterisk -rvv
Asterisk 17.6.0, Copyright (C) 1999 - 2018, 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 17.6.0 currently running on ubuntu (pid = 54142)
ubuntu*CLI>

If you have an active ufw firewall, please open http port and port 5060,5061:

sudo ufw allow proto tcp from any to any port 5060,5061

Now you have installed Asterisk 17 and can use it on Ubuntu 20.04 | 18.04 Linux server.

More guides on VoIP.

Protect Asterisk and FreePBX from VoIP fraud and brute force attacks

How to install FreeSwitch PBX on Ubuntu

To
You can download this article in PDF format via the link below to support us.

Download the guide in PDF format

turn off
To

To
To

Sidebar