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 is a popular open-source PBX platform for developing communications applications such as conference servers and VoIP gateways. It offers a set of features including, conference call, voice mail, IVR, and automatic call distribution. It is used by individuals, small businesses, large enterprises, and governments worldwide.

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 through 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.

Install Asterisk on Ubuntu 20.04 LTS Focal Fossa

Step 1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

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!