How to Install Asterisk on Ubuntu 16.04

How to Install Asterisk on Ubuntu 16.04

Spread the love

In this tutorial, we will show you how to install Asterisk on an Ubuntu 16.04 server. Asterisk is the most popular open source software implementation of a telephone private branch exchange (PBX). It includes many features such as: voicemail, conference calling, call recorder, automatic call distribution, interactive voice response, real time monitoring, debugging console and supports most of the standard voice over IP (VOIP) protocols including SIP, d H.323 and MGCP.

Login via SSH and update the OS

Make sure your server OS is fully up-to-date:

apt-get update
apt-get upgrade

Install all required packages and dependencies

Install all required packages on your Asterisk VPS with the following commands:

apt-get install build-essential
apt-get install git-core subversion libjansson-dev sqlite autoconf automake libxml2-dev libncurses5-dev libtool

Download Asterisk

At the time of the writing of this article the latest Asterisk version is 15.5.0, switch to the /usr/src/directory with:

cd /usr/src/

and download the asterisk archive with the following wget command:

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

When the download is completed extract the asterisk-15-current.tar.gz file by typing the following command:

tar -zxvf asterisk-15-current.tar.gz

Compile Asterisk

Once the asterisk archive is extracted, switch to the asterisk-15.5.0 directory with:

cd /usr/src/asterisk-15.5.0

Install all of the missing dependencies with the help of the install_prereq script:

./contrib/scripts/install_prereq install

Depending on the number of the missing packages the installation may take some time , once it is completed the output will look like this:

Current status: 7 (-2) upgradable.
#############################################
## install completed successfully
#############################################

Next step is to run the ./configure script which will check your system for missing libraries and dependencies and prepare the Asterisk code for the build process:

./configure 

The output of the successful completion should look like this:

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 :

Once the configuration is completed start the compilation process using the make command by typing:

make

The build process may take several minutes depending on your system speed and once it is completed you will see the following message which means that the Asterisk was successfully compiled:

+--------- Asterisk Build Complete ---------+
+ Asterisk has successfully been built, and +
+ can be installed by running:              +
+                                           +
+                make install               +
+-------------------------------------------+

The next step is to run the make install command which will install Asterisk and all compiled Asterisk modules:

make install

Upon successful Asterisk installation you will see the following message on your screen:

 +---- 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    +
 +-------------------------------------------+

As the message above says run the make samples command to install the Asterisk sample configuration files:

make samples

Install the initialization script so that you can manage your Asterisk service using the systemctl command :

make config

The command above will show no output.

You can also install the logrotation script with:

make install-logrotate

You will see the following output indicating that the logrotation configuration has been successfully created:

if [ ! -d "/etc/asterisk/../logrotate.d" ]; then \
        /usr/bin/install -c -d "/etc/asterisk/../logrotate.d" ; \
fi
sed 's#__LOGDIR__#/var/log/asterisk#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#/usr/sbin#g' > contrib/scripts/asterisk.logrotate.tmp
/usr/bin/install -c -m 0644 contrib/scripts/asterisk.logrotate.tmp "/etc/asterisk/../logrotate.d/asterisk"
rm -f contrib/scripts/asterisk.logrotate.

Start Asterisk

Now that you have Asterisk installed on your Ubuntu 16.04 VPS you can use the systemctl to start the Asterisk service:

systemctl start asterisk

To check if the Asterisk service is started use the systemctl status command:

systemctl status asterisk

If the service is running you will see the following message:

● asterisk.service - LSB: Asterisk PBX
   Loaded: loaded (/etc/init.d/asterisk; bad; vendor preset: enabled)
   Active: active (running) since Wed 2018-07-18 03:36:23 CDT; 5s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 15427 ExecStart=/etc/init.d/asterisk start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/asterisk.service
           └─15440 /usr/sbin/asterisk

To enable the asterisk service to start on system boot type the following command:

systemctl enable asterisk

That is it. The Asterisk installation is complete.


Install Asterisk on Ubuntu 16.04Of course you don’t have to install Asterisk on Ubuntu 16.04 yourself if you use our Premium Server Support Services, in which case you can simply ask our expert Linux admins to install Asterisk on Ubuntu 16.04 for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this on how to install Asterisk on Ubuntu 16.04, post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

12 thoughts on “How to Install Asterisk on Ubuntu 16.04

      1. I have the same issue, at the end of the installation. Executing `systemctl status asterisk` I see the same result as yours and further the next message:

        asterisk[22143]: rc_read_config: can’t open /etc/radiusclient-ng/radiusclient.conf: No such file or directory

  1. You can fix that error by following the directions:

    sed -i ‘s”;\[radius\]”\[radius\]”g’ /etc/asterisk/cdr.conf
    sed -i ‘s”;radiuscfg => /usr/local/etc/radiusclient-ng/radiusclient.conf”radiuscfg => /etc/radcli/radiusclient.conf”g’ /etc/asterisk/cdr.conf
    sed -i ‘s”;radiuscfg => /usr/local/etc/radiusclient-ng/radiusclient.conf”radiuscfg => /etc/radcli/radiusclient.conf”g’ /etc/asterisk/cel.conf

    Then I did a “service asterisk restart” followed by “service asterisk status” which correctly showed the issue was resolved.

  2. Which of the steps require sudo, if any?

    Also, after the Asterisk Build Complete step there is:

    “The next step is to run the make install command which will install Asterisk and all compiled Asterisk modules:

    make”

    Is there a typo? Should the command be make install?

    Thanks.

    1. We used our “root” account to do the installation, it doesn’t need “sudo”. You can use “sudo” command if you do the installation using a sudoer, other than root.
      The typo has been corrected, thanks!

  3. Thanks for the very detailed steps. Though I didn’t understand fully each step, the output of my every step matches these detailed instructions. I ran every step with sudo.

    There’s one typo though. The second `make` should be `make install`.

  4. Hey Thanks for this guide I am a newbie to this and installed asterisk in local environment now i want to know any guide for configuring numbers and connecting this server to cross platform soft-phone for lan communication and chat

  5. i got below messages when i enter “sudo systemctl status asterisk”

    9월 25 18:55:21 ubuntu16 asterisk[14647]: rc_read_dictionary couldn’t open diction
    9월 25 18:55:21 ubuntu16 asterisk[14647]: could not load dictionary
    9월 25 18:55:21 ubuntu16 asterisk[14647]: rc_read_dictionary couldn’t open diction
    9월 25 18:55:21 ubuntu16 asterisk[14647]: could not load dictionary

    so i just make a directory “/etc/radcli/dictionary” and the above message is gone.

Leave a Reply

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