How to Install Asterisk on Ubuntu

You need to install Asterisk on Ubuntu if you ever need a solution to effortlessly transform your computer into an IP PBX system or VoIP gateways-powered communication server.

When we talk about Asterisk, we’re looking at an open-source software designed to help users modify their computers into a communication server irrespective of how robust their systems are. The tool is written in the C Programming Language and is built to run on various types of Unix like Linux. 

Asterisk loads up with amazing features that include voicemail, conference calling, call recording, interactive voice response, and more. All thanks to these, it is used by businesses, individuals, and even government bodies to carry out various communication-based functionalities with ease.

Learn the process to install Asterisk on Ubuntu within minutes. 

How to Install Asterisk on Ubuntu

Installing and using Asterisk is a pretty straightforward process. Here we have the six-step process that will let you set up and initiate Asterisk on Ubuntu.

1. Get your Ubuntu System Updated

The first thing that you’ll need to do is get your APT package index updated. It is always better to start with a new system so that the installation doesn’t affect any running services. For having the packages installed on your system updated, launch the Terminal by using the shortcut “Ctrl+Alt+T” and running the following command:

sudo apt update
sudo apt -y upgrade
update

2. Reboot the System

reboot

On successful up-gradation of the APT packages, the next thing to do is reboot your system. For that, run the following command:

sudo systemctl reboot

3. Install Build Dependencies

Launch the Terminal one more time and run the following command to install all the dependencies that are crucial for installing and building Asterisk on Ubuntu as soon as your system is rebooted. During the entire process, make sure to have a stable internet connection.

sudo apt update
sudo add-apt-repository universe
sudo apt -y install git curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev build-essential libjansson-dev libxml2-dev uuid-dev

4. Downloading Asterisk 

In case you’re wondering if Asterisk is available in the official system repository or not, the answer is a straightforward no. With that being said, you’ll have to install the Asterisk tarball and set up the application manually.

1. Check the available version by running the command:

sudo apt policy asterisk
Install Asterisk on Ubuntu

2. After that, make use of the wget command to download the required archive file

cd ~
wget http://downloads.asterisk.org/telephony/asterisk-18.tar.gz
 Asterisk on Ubuntu link

3. Have the file extracted with Tar

tar xvf asterisk-18-current.tar.gz

4. The next thing to do is download the mp3 decoder library into your source tree. The process is pretty straightforward, and you’ll just have to run the following command:

cd asterisk*18/
contrib/scripts/get_mp3_source.sh

5. Double-check if all the dependencies are resolved or not, using the following command:

sudo contrib/scripts/install_prereq install

This should lead to a successful message stating that “installation completed successfully.”

Success

5. Building Asterisk on Ubuntu

1. As your system successfully concludes the process of installing dependencies, you’re ready to build and run Asterisk. But before moving any further, run the configure script and ensure all the build dependencies are satisfied

./configure

Running the script should display a success output like the one in the image down.

Asterisk Ubuntu

2. Next up, run the following command and get yourself into the setup menu options

make menuselect
Recording

3. You’ll then come across a menu from where you can build your Asterisk. Navigation is pretty simple; all you need to use are the arrow keys, while you can use the “Enter” key to select the menu. Carefully select the desired add-ons, Core sound, and MOH packages. 

4. After you’re done selecting the menus, run the following command and confirm the Asterisk build on Ubuntu

make 

Check if the output displays something like:

Installation

5. Once done, install Asterisk using the command:

sudo make install

6. In case you wish to get the documentation installed, use the following command:

sudo make progdocs

7. Lastly, get the configs and samples installed by running the command:

sudo make samples
sudo make config
sudo ldconfig

6. Initiate Asterisk Services on Ubuntu

1. To initiate Asterisk services on your Ubuntu system, you’ll first need to create a separate user and a group. Do that by running the following command:

sudo groupadd asterisk
sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk
sudo usermod -aG audio,dialout asterisk
sudo chown -R asterisk.asterisk /etc/asterisk
sudo chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
sudo chown -R asterisk.asterisk /usr/lib/asterisk

2. After that, set Asterisk as the default user

$ sudo vim /etc/default/asterisk
AST_USER="asterisk"
AST_GROUP="asterisk"

$ sudo vim /etc/asterisk/asterisk.conf
runuser = asterisk ; The user to run as.
rungroup = asterisk ; The group to run as.
Run

3. Then, restart Asterisk using the command:

sudo systemctl restart asterisk

4. After that, run the following command and enable the Asterisk services to make it start on system boot. 

sudo systemctl enable asterisk

5. Verify if the services are running properly using the command:

$ systemctl status asterisk

Configuring Firewall for Asterisk on Ubuntu

Launch the default UDP port 5060 by running the command:

sudo ufw allow 5060/udpCopy

Those operating in the Real-Time Protocol (RTP) will need to open the following port range:

sudo ufw allow 10000:20000/udp

And this is pretty much everything about downloading, building, and running the Asterisk services on Ubuntu. Follow these steps and transform your Linux system into a communication server within minutes. 

Leave a Reply
Related Posts