In this article, we will have explained the necessary steps to install and configure Asterisk on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo
privileges. All the commands in this tutorial should be run as a non-root user.
Asterisk is a popular open-source PBX platform for developing communications applications such as conference servers and VoIP gateways. Asterisk is a software-based solution that turns your old computer into a communications server that powers IP PBX systems, VoIP gateways, conference servers, and other custom solutions. The solutions build by Asterisk powers call centers, carriers, and government agencies worldwide.
Install Asterisk on Ubuntu 20.04
Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.
sudo apt update sudo apt upgrade sudo apt install wget build-essential git autoconf subversion pkg-config libtool
Step 2. Install Asterisk on Ubuntu system.
Download the latest version of Asterisk from the Asterisk official website using the following command:
sudo git clone -b 18 https://gerrit.asterisk.org/asterisk asterisk-18
Next, change the directory to the extracted directory:
cd asterisk-18/
Run the following command to download the mp3 decoder library into the source tree:
sudo contrib/scripts/get_mp3_source.sh sudo contrib/scripts/install_prereq install
You’ll see the below message upon successful installation:
############################################# ## install completed successfully ## #############################################
After installation of dependencies, you should be ready to build Asterisk 18 from the source we downloaded:
sudo ./configure sudo make menuselect
Select the “format_mp3” option to tell Asterisk to build the MP3 module:
After that select the “Save and Exit” button and press “Enter” and start the compilation process:
sudo make -j2
Once completed, install and configuration Asterisk and its modules by following commands:
sudo make install sudo make samples sudo make basic-pbx sudo make config sudo ldconfig
Step 3. Create an Asterisk User.
Now add the asterisk user and group & give access to the specific permissions as required:
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
And choose the asterisk for the default user of Asterisk:
sudo nano /etc/default/asterisk
Add the following line:
AST_USER="asterisk" AST_GROUP="asterisk"
Also edit:
sudo nano /etc/asterisk/asterisk.conf
Add the following line:
runuser = asterisk ; The user to run as. rungroup = asterisk ; The group to run as.
After this configuration, restart the Asterisk services:
sudo systemctl start asterisk
To verify that Asterisk is running, connect to the Asterisk command-line interface by typing:
sudo asterisk -vvvr
Step 4. Configuring Firewall.
If you have an active ufw firewall, open HTTP ports and ports 5060,5061:
sudo ufw allow proto tcp from any to any port 5060,5061
That’s all you need to do to install Asterisk on Ubuntu 20.04 LTS Focal Fossa. I hope you find this quick tip helpful. For further reading on Install Asterisk open-source framework for building communications applications, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.