Ubuntu

How to Install Asterisk on Ubuntu 22.04

Asterisk is a freely available open-source PBX platform that is utilized for creating communication software such as VoIP gateways and conference servers. It is primarily used by governments, major corporations, small businesses, and individuals. SMS messaging, music on hold, call recording, call queuing, voicemail, interactive voice response, and conference calling are some of the fantastic features of Asterisk.

This blog will demonstrate the procedure of installing Asterisk on Ubuntu 22.04. Let’s get started.

How to install Asterisk on Ubuntu 22.04

For the purpose of installing Asterisk on Ubuntu 22.04, follow the given instructions.

Step 1: Update system packages
First of all, hit “CTRL+ALT+T” and update the system packages:

$ sudo apt update

All packages are updated:

Step 2: Packages installation
Next, move towards the essential packages installation:

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

All the essential packages are installed, let’s move to the next step.

Step 3: Download Asterisk archive file
Move to the “/usr/src/” for downloading the Asterisk file on the local system:

$ cd /usr/src/

Next, execute the provided “curl” command to download Asterisk archive file:

$ sudo curl -O http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz

Step 4: Extract Asterisk file
Extract the downloaded Asterisk file:

$ sudo tar xvf asterisk-16-current.tar.gz

Step 5: Move to Asterisk directory
Run the following command to move into the “asterisk-16*” directory:

$ cd asterisk-16*/

Step 6: Download MP3 decoder library
In the next step, we will download the MP3 decoder library in the current Asterisk directory:

$ sudo contrib/scripts/get_mp3_source.sh

Then, make sure all of the dependencies are resolved:

$ sudo contrib/scripts/install_prereq install

Specify the “numeric code” of your region and hit “Enter”:

The given output indicates that the dependencies are successfully resolved:

Type “./configure” for satisfying build dependencies:

$ sudo ./configure

Step 7: Set up menu options
In the next step, we will set up some menu options by utilizing the provided command:

$ sudo make menuselect

For instance, we have selected “chan_ooh323” as “Add-ons”. Use the arrow keys and select other build options. After setting the options according to the requirements, hit the “Save & Exit” button:

Step 7: Build Asterisk
Next, type out “sudo make” in the Ubuntu 22.04 terminal for building Asterisk:

$ sudo make

Step 8: Install Asterisk
Then, install Asterisk on your Ubuntu 22.04 system with the help of the provided command:

$ sudo make install

Step 9: Install samples and configs
After installing Asterisk, move ahead and install “samples” and “configs” one by one:

$ sudo make samples

$ sudo make config

$ sudo ldconfig

Upon doing so, the Asterisk service unit file is created on your Ubuntu 22.04 system.

Step 10: Create Asterisk User
In order to run the Asterisk service, firstly create an “asterisk” user and group:

$ sudo groupadd asterisk

Step 11: Set permissions
Next, set the correct permissions for the “asterisk” user:

$ sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk

$ sudo usermod -aG audio,dialout asterisk

One by one, execute the below-given command:

$ sudo chown -R asterisk.asterisk /etc/asterisk

The second command you need to run is:

$ sudo chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk

Lastly, execute the given command:

$ sudo chown -R asterisk.asterisk /usr/lib/asterisk

Step 12: Set Asterisk user
Now, we will set the created “asterisk” user as the default Asterisk user. To do so, open up the Asterisk configuration file in the “nano” editor:

$ sudo nano /etc/default/asterisk

You Asterisk configuration file will somehow look like this:

Now specify the default Asterisk user and its group as follows:

AST_USER="asterisk"
AST_GROUP="asterisk"

Then press “CTRL+O” to save the added lines and switch back to terminal:

Step 13: Restart Asterisk service
After performing the previous operation, restart the Asterisk service on your system:

$ sudo systemctl restart asterisk

Step 14: Enable Asterisk service
Next, enable the Asterisk service so that it can start on system boot:

$ sudo systemctl enable asterisk

Step 15: Check Asterisk service status
Lastly verify if the Asterisk service is successfully running on your system:

$ systemctl status asterisk

That was all about Asterisk installation. Now, let’s head towards the method of connecting to Asterisk CLI.

How to connect to Asterisk CLI on Ubuntu 22.04

Run the following command in Ubuntu 22.04 terminal for connecting to the Asterisk CLIU:

$ sudo asterisk -rvv

The above-given output shows that we are successfully connected to the Asterisk CLI.

How to remove Asterisk from Ubuntu 22.04

On Ubuntu 22.04 terminal, run the provided command for removing Asterisk:

$ sudo rm -r /usr/src/asterisk-16.26.1

We have compiled the easiest method to install Asterisk on Ubuntu 22.04 system.

Conclusion

To install Asterisk on Ubuntu 22.04, firstly install the required dependencies, download the Asterisk archive file and extract the downloaded package. Then, satisfy the build dependencies, set up menu options, build, and install Asterisk. To configure Asterisk, you can create a separate “asterisk” user and group and set their permissions. This blog demonstrated the procedure to install Asterisk on Ubuntu 22.04.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.