In this article, we are going to shows how to Install Asterisk PBX on Ubuntu 20.04 | 18.04 . If you are interested to Install Asterisk PBX on your Ubuntu system then this post is ideal for you.
Asterisk is a popular open-source and widely used PBX(private branch exchange) platform for building communications applications such as conferencing infrastructures and VoIP gateways.
Asterisk comes with a set of features including, conference calling, interactive voice response, voicemail, call queuing, call recording, music on hold, SMS messaging and many other features.
For more details about Asterisk, please check its official website.
How to Install Asterisk PBX on Ubuntu
Simply follow below steps to install Asterisk on your Ubuntu machine :
Step 1 : Install Required Packages
First of all, you will need to install some required packages that are necessary to download and run Asterisk. To do that, run the commands below:
sudo apt update
sudo apt install wget build-essential git autoconf subversion pkg-config libtool
Step 2 : Download and Install Asterisk
To download the latest version of Asterisk from the Asterisk official website, run the command below:
cd /usr/src/
sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz
At this time, the latest version of Asterisk is version 18.4.0. To check the new and stable version of Asterisk, visit its Download page.
Next, change the directory to its directory and run the installation script as show below:
sudo tar zxf asterisk-18-current.tar.gz
cd asterisk-18.*/
sudo contrib/scripts/get_mp3_source.sh
sudo contrib/scripts/install_prereq install
The commands above will download and install all dependencies, including MP3 sources which are required to build the MP3 module and use MP3 files on Asterisk.
After that, you will need to perform some checks and validate that all of the dependencies on your system are present. To do that, run the configure
script as show below:
sudo ./configure
The above command will display a output similar like below:
configure: Menuselect build configuration successfully completed
.$$$$$$$$$$$$$$$=..
.$7$7.. .7$$7:.
.$$:. ,$7.7
.$7. 7$$$$ .$$77
..$$. $$$$$ .$$$7
..7$ .?. $$$$$ .?. 7$$$.
$.$. .$$$7. $$$$7 .7$$$. .$$$.
.777. .$$$$$$77$$$77$$$$$7. $$$,
$$$~ .7$$$$$$$$$$$$$7. .$$$.
.$$7 .7$$$$$$$7: ?$$$.
$$$ ?7$$$$$$$$$$I .$$$7
$$$ .7$$$$$$$$$$$$$$$$ :$$$.
$$$ $$$$$$7$$$$$$$$$$$$ .$$$.
$$$ $$$ 7$$$7 .$$$ .$$$.
$$$$ $$$$7 .$$$.
7$$$7 7$$$$ 7$$$
$$$$$ $$$
$$$$7. $$ (TM)
$$$$$$$. .7$$$$$$ $$
$$$$$$$$$$$$7$$$$$$$$$.$$$$$$
$$$$$$$$$$$$$$$$.
configure: Package configured for:
configure: OS type : linux-gnu
configure: Host CPU : x86_64
configure: build-cpu:vendor:os: x86_64 : pc : linux-gnu :
configure: host-cpu:vendor:os: x86_64 : pc : linux-gnu :
After that, select the modules you want to compile and install. To access the menu select, run the command below:
sudo make menuselect
Select the format_mp3 option:
┌──────────┤ Asterisk Module and Build Option Selection ├─────────┐
| |
│ Add-ons (See README-addons.txt) --- Extended --- ↑ │
│ Applications [ ] chan_mobile ▒ │
│ Bridging Modules [ ] chan_ooh323 ▒ │
│ Call Detail Recording [*] format_mp3 ▒ │
│ Channel Event Logging [ ] res_config_mysql ▒ │
│ Channel Drivers --- Deprecated --- ▒ │
│ Codec Translators [ ] app_mysql ▒ │
│ Format Interpreters [ ] cdr_mysql ▮│
│ Dialplan Functions ▒ │
│ PBX Modules ▒ │
│ Resource Modules ▒ │
│ Test Modules ▒ │
│ Compiler Flags ▒ │
│ Utilities ▒ │
│ AGI Samples ↓ │
│ │
│ MP3 format [Any rate but 8000hz mono is optimal] │
│ │
│ Depends on: N/A ┌───────────────┐ ┌──────────┐ │
│ Can use: N/A │ Save & Exit │ │ Exit │ │
│ Conflicts with: N/A └───────────────┘ └──────────┘ │
│ Support Level: extended |
└─────────────────────────────────────────────────────────────────┘
toggles selection | saves & exits | exits without save
After select, press F12 or select the Save and Exit button and press Enter.
Next, run the commands below to start compilation process:
sudo make -j2
The compilation process take some time depending on your machine. The -j option with the number indicates the number of CPU’s on your server. If your server has more then 2 CPU cores, then you can modify it according to the number of CPU’s on your server.
Once the compilation process completed, it will display a output similar like below:
+--------- Asterisk Build Complete ---------+
+ Asterisk has successfully been built, and +
+ can be installed by running: +
+ +
+ make install +
+-------------------------------------------+
Finally install Asterisk using command below:
sudo make install
After complete the installation, it will display a output similar like below:
+---- Asterisk Installation Complete -------+
+ +
+ YOU MUST READ THE SECURITY DOCUMENT +
+ +
+ Asterisk has successfully been installed. +
+ If you would like to install the sample +
+ configuration files (overwriting any +
+ existing config files), run: +
+ +
+ For generic reference documentation: +
+ make samples +
+ +
+ For a sample basic PBX: +
+ make basic-pbx +
+ +
+ +
+----------------- or ---------------------+
+ +
+ You can go ahead and install the asterisk +
+ program documentation now or later run: +
+ +
+ make progdocs +
+ +
+ **Note** This requires that you have +
+ doxygen installed on your local system +
+-------------------------------------------+
Once completed, you can configure your system for Asterisk and its modules. To do that, run the commands below:
sudo make samples
sudo make basic-pbx
The command above add some samples data to configuring your system.
Next, run the commands below to finish the configuration process:
sudo make config
sudo ldconfig
Step 3 : Create an Asterisk User
By default Asterisk runs as the root user. So you will need to create a new user to run Asterisk.
To create a new a user and a group named asterisk
, run the command below:
sudo addgroup --quiet --system asterisk
sudo adduser --quiet --system --ingroup asterisk --no-create-home --disabled-password asterisk
Next, open the /etc/default/asterisk file and set the default user to Asterisk as show below:
sudo nano /etc/default/asterisk
After open the file, Uncomment the highlighted lines below:
# Startup configuration for the Asterisk daemon
# Uncomment the following and set them to the user/groups that you
# want to run Asterisk as. NOTE: this requires substantial work to
# be sure that Asterisk's environment has permission to write the
# files required for its operation, including logs, its comm
# socket, the asterisk database, etc.
AST_USER="asterisk"
AST_GROUP="asterisk"
Next, add the asterisk user to the dialout and audio groups:
sudo usermod -a -G dialout,audio asterisk
Next, you need to change the permissions and the ownership of all Asterisk files and directory to make its users owner:
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
To enable and start Asterisk service, run the commands below:
sudo systemctl enable asterisk
sudo systemctl start asterisk
To verify that Asterisk is running and working properly, run the commands below:
sudo asterisk -vvvr
Step 5 : Configure Firewall
If you have an enabled firewall then you will need to allow the ports below.
By default, SIP uses the UDP port 5060. To allow the following port, run the command below:
sudo ufw allow 5060/udp
For Real Time Protocol (RTP), you will need to allow the following port range:
sudo ufw allow 10000:20000/udp
That’s all
If you face any error and issue in above steps , please use comment box below to report.
If our tutorials helped you, please consider buying us a coffee. We appreciate your support!
Thank you for your support.