LinuxTutorialsUbuntu

How To Install Asterisk on Ubuntu 20.04 LTS

Install Asterisk on Ubuntu 20.04

In this tutorial, we will show you how to install Asterisk on Ubuntu 20.04 LTS. For those of you who didn’t know, Asterisk, an open-source software framework for building communications applications, has revolutionized the world of VoIP and telephony systems. With its powerful features and customizable nature, Asterisk has become a go-to solution for businesses and individuals looking to implement robust and cost-effective communication solutions.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Asterisk on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.

Prerequisites

  • A server running one of the following operating systems: Ubuntu 20.04, 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Asterisk on Ubuntu 20.04 LTS Focal Fossa

Step 1. To begin, we need to update the system’s package index and install the necessary packages for building Asterisk from source. Open a terminal and run the following commands:

sudo apt update
sudo apt upgrade
sudo apt install wget build-essential git autoconf subversion pkg-config libtool

Step 2. Installing Asterisk on Ubuntu 20.04.

Now we download the latest version of Asterisk from the Asterisk official website using the following command:

cd /usr/src/
sudo git clone -b 18 https://gerrit.asterisk.org/asterisk asterisk-18

Next, change the directory to the extracted directory and install all required MP3 modules with the following command:

cd asterisk-18/
sudo contrib/scripts/get_mp3_source.sh

After that, install other dependencies with the following command:

sudo contrib/scripts/install_prereq install

You should get a success message at the end:

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

After the installation of dependencies, you should be ready to build Asterisk 18 from the source we downloaded:

sudo ./configure

The next step is to select the modules you want to compile and install. Access menu selects, by typing:

sudo make menuselect

Select the “format_mp3” option to tell Asterisk to build the MP3 module:

Install Asterisk on Ubuntu 20.04

Once you are finished, switch to the “Save and Exit” button and press “Enter” and start the compilation process:

sudo make -j2
sudo make install
sudo make samples
sudo make basic-pbx
sudo make config
sudo ldconfig

Step 3. Create an Asterisk User.

Now run the following command to create a new system user named asterisk:

sudo adduser --system --group --home /var/lib/asterisk --no-create-home --gecos "Asterisk PBX" asterisk

After that, edit the /etc/default/asterisk file and set default user to Asterisk:

sudo nano /etc/default/asterisk

Uncomment the following lines:

AST_USER="asterisk"
AST_GROUP="asterisk"

Next, add audio and dial-out user to Asterisk group by running the following command:

usermod -aG audio,dialout asterisk

Then, change the ownership of the Asterisk configuration directory with the following command:

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

Step 4. Starting Asterisk.

At this point, all is done. Run the commands below to enable and start the Asterisk service:

sudo systemctl enable asterisk
sudo systemctl start asterisk

To verify that Asterisk is running, run the commands below:

sudo asterisk -vvvr

Step 5. Configure Firewall.

If you have an active UFW firewall, open HTTP ports and ports 5060,5061:

sudo ufw allow 5060/udp
sudo ufw allow 10000:20000/udp

Congratulations! You have successfully installed Asterisk. Thanks for using this tutorial for installing the Asterisk on your Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official Asterisk website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button