IPTISP/PBX Configuration: Install Asterisk on Ubuntu

Step 1: Update Ubuntu System


zaman@zaman:~$ sudo apt update -y

zaman@zaman:~$ sudo apt -y upgrade


Reboot your system

zaman@zaman:~$ sudo systemctl reboot


Step 2: Install Build Dependencies


zaman@zaman:~$ sudo apt update

zaman@zaman:~$ sudo add-apt-repository universe

zaman@zaman:~$ sudo apt -y install git curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev build-essential libjansson-dev libxml2-dev  uuid-dev


Step 3: Download Asterisk 18 tarball


zaman@zaman:~$ 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


Visit https://www.asterisk.org/ to download the asterisk source code

zaman@zaman:~$ cd ~

zaman@zaman:~$ wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz


Extract the file with tar

zaman@zaman:~$ tar xvf asterisk-18-current.tar.gz


Run the command to download the mp3 decoder library into the source tree

zaman@zaman:~$ cd asterisk-18*/

zaman@zaman:~$ contrib/scripts/get_mp3_source.sh


Ensure all dependencies are resolved

zaman@zaman:~$ sudo contrib/scripts/install_prereq install


Step 4: Build and Install Asterisk on Ubuntu


Run the configure script to satisfy build dependencies

zaman@zaman:~$ ./configure


Setup menu options by running the following command

zaman@zaman:~$ make menuselect

Use arrow keys to navigate, and Enter key to select


Select Add-ons to enable:


Enable Core sound modules you want to use:


You can also add additional MOH packages you want to use:


Do the same for Extra Sound Packages:


You can also go through the other menus and select options you see fit for your use case.


When done run the command to build Asterisk on Ubuntu

zaman@zaman:~$ make

Run the command to install Asterisk on Ubuntu

zaman@zaman:~$ sudo make install

You can optionally install documentation

zaman@zaman:~$ sudo make progdocs


Finally, install configs and samples

zaman@zaman:~$ sudo make samples

zaman@zaman:~$ sudo make config

zaman@zaman:~$ sudo ldconfig


Step 5: Start Asterisk Service on Ubuntu


Create a separate user and group to run asterisk services, and assign correct permissions


zaman@zaman:~$ sudo groupadd asterisk

zaman@zaman:~$ sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk

zaman@zaman:~$ sudo usermod -aG audio,dialout asterisk

zaman@zaman:~$ sudo chown -R asterisk.asterisk /etc/asterisk

zaman@zaman:~$ sudo chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk

zaman@zaman:~$ sudo chown -R asterisk.asterisk /usr/lib/asterisk


Set Asterisk default user to asterisk

zaman@zaman:~$ sudo vim /etc/default/asterisk

AST_USER="asterisk"

AST_GROUP="asterisk"


zaman@zaman:~$ sudo vim /etc/asterisk/asterisk.conf

runuser = asterisk ; The user to run as.

rungroup = asterisk ; The group to run as.


Restart asterisk service after making the changes

zaman@zaman:~$ sudo systemctl restart asterisk


Enable asterisk service to start on system  boot

zaman@zaman:~$ sudo systemctl enable asterisk


Check service status to see if it is running

zaman@zaman:~$ systemctl status asterisk


Verify you can connect to Asterisk Command Line interface

zaman@zaman:~$ sudo asterisk -rvv

Asterisk 18.1.1, Copyright (C) 1999 - 2018, Digium, Inc. and others.

Created by Mark Spencer markster@digium.com

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 18.1.1 currently running on asterisk (pid = 107650)

asterisk*CLI>



If you have an active ufw firewall, open http ports and ports 5060,5061

zaman@zaman:~$ sudo ufw allow proto tcp from any to any port 5060,5061


You now have Asterisk installed and working on Ubuntu Linux server.









*****

0 Comments