Asterisk is an open-source framework for building communications applications. Asterisk turns an ordinary computer into a communications server by powering IP PBX systems, VoIP gateways, conference servers and other custom solutions. Small businesses use it, large companies, call centres, carriers and government agencies, worldwide. Asterisk supports several standard voice-over IP protocols, including the Session Initiation Protocol (SIP), the Media Gateway Control Protocol (MGCP), and H.323.

In this guide, we will explain how to install Asterisk on a Debian 9 server.

sudo apt install wget build-essential subversion

Prerequisites: Add SIP Ports to Config Server Firewall (CSF)
Ports 5060 and 5061, both on TCP and UDP, are associated with the Session Initiation Protocol (SIP) by IANA. Hence, we will need to add these ports to our csf.conf file.

You can read our guide on configuring CSF on Ubuntu and CentOS for more information on CSF.

sudo nano /etc/csf/csf.conf

Reload CSF to enforce our changes with the command below:

sudo csf -r

Step 1: Download Asterisk
Navigate to the /usr/src directory and download Asterisk using the wget command. At the time of writing this guide, the latest stable version of Asterisk is version 17.

Change to the and download the Asterisk source code with the following wget command:

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

Next, extract the downloaded archive using the tar command, as shown below:

sudo tar zxf asterisk-17-current.tar.gz

After extracting, change your working directory to the Asterisk directory:

cd asterisk-17.*/

Step 2: Install Asterisk Dependencies
There are a couple of dependencies required for Asterisk to work correctly. First, issue the script below to download the MP3 sources which are required to build the MP3 module and use MP3 files:

sudo contrib/scripts/get_mp3_source.sh

Next, run the install_prereq script to resolve all of the dependencies on our Debian system:

sudo contrib/scripts/install_prereq install

Next, you will see the default ITU-T telephone code of 61. But in our case, we are changing it to 234 for Nigeria.

Upon completion, this should be displayed:

Step 3: Install Asterisk
After installing dependencies, we can now install Asterisk by issuing the configure script which will get the Asterisk code ready to compile:

sudo ./configure

This will start the build process with a menu appearing shortly on screen, allowing you to configure the features you want to build.

sudo make menuselect

To use the MP3 format with Music on Hold, you should select Add-Ons, navigating to format_mp3 and selecting it. Select additional core sound packages and Music on Hold packages in the left menu, and enable .wav format for your desired language. You can use F12 to save and exit. Next, begin the compilation process using the make command:

sudo make

Lastly, we can now install Asterisk and install sample configuration files:

 sudo make install

Next, we can install the generic configuration files with sample documentation by issuing the command below:

sudo make samples

We can also install the basic PBX configuration files by issuing the command below:

sudo make basic-pbx

Lastly, install the Asterisk init script which configures Asterisk to start itself automatically on boot:

sudo make config

You can also run ldconfig to update the shared libraries cache:

sudo ldconfig

For more detailed instructions on configuring Asterisk, visit the Asterisk Project’s guide