×


Install Asterisk on Ubuntu 20.04 - Step by step guide ?

Asterisk is a popular open-source that allows you to create communications applications such as VoIP gateways and conference servers. It is a useful choice for call centers, small businesses, and governments worldwide.

Based on VoIP protocol, Asterisk allows us to make TCP/IP calls for free. 

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Open-source Software Installation and configuration queries.

In this context, we shall look into how to install Asterisk on Ubuntu 20.04.


Steps to install Asterisk on Ubuntu Linux system

1. Perform System Update

Run the below apt command to update the system's apt packages:

$ sudo apt update


2. Install Software Dependencies

Here, execute the below command to install Asterisk's Software dependecies:

$ sudo apt-get install gnupg2 software-properties-common git curl wget libnewt-dev libssl-dev libncurses5-dev autoconf subversion libsqlite3-dev build-essential libjansson-dev libxml2-dev pkg-config subversion libtool uuid-dev -y


3. Install DAHDI and LibPRI

Asterisk communicates with digital and analog phones by DAHDI. Asterisk communicates with ISDN connections by the LibPRI library. The installation of these 2 is required.

Navigate to /usr/src directory and install DAHDI:

$ cd /usr/src/

Then execute:

$ sudo git clone -b next git://git.asterisk.org/dahdi/linux dahdi-linux

Next,  navigate to dahdi-linux and run the command:

$ cd dahdi-linux
$ sudo make
$ sudo make install

Now, you can run the below commands:

$ cd /usr/src/
$ sudo git clone -b next git://git.asterisk.org/dahdi/tools dahdi-tools
$ cd dahdi-tools
$ sudo autoreconf -i
$ sudo ./configure
$ sudo make install
$ sudo make install-config
$ sudo dahdi_genconf modules

To build LibPRI, execute:

$ cd /usr/src/
$ sudo git clone https://gerrit.asterisk.org/libpri libpri
$ cd libpri
$ sudo make
$ sudo make install


4. Install Asterisk

Navigate to /usr/src directory and clone the Asterisk source:

$ cd /usr/src/
$ sudo git clone -b 18 https://gerrit.asterisk.org/asterisk asterisk-18

Next, navigate to asterisk-18:

$ cd asterisk-18/

Here, Download the MP3 sources:

$ sudo contrib/scripts/get_mp3_source.sh

Run the install_prereq script:

$ sudo contrib/scripts/install_prereq install

Type your ITU-T telephone code and press Ok.

Then run:

$ sudo ./configure
$ sudo make menuselect

Select format_mp3 and Save & Exit.

Start compiling with the command:

$ sudo make -j2

Once done, install Asterisk:

$ sudo make install

Install either the generic configuration files:

$ sudo make samples

Finally, install the Asterisk init script:

$ sudo make config

Update shared libraries cache:

$ sudo ldconfig


5. Create Asterisk User

You can Create a user name asterisk with the below command:

$ sudo adduser --system --group --home /var/lib/asterisk --no-create-home --gecos "Asterisk PBX" asterisk

To configure Asterisk, use the command:

$ nano /etc/default/asterisk

Then, Add asterisk to the groups:

$ sudo usermod -a -G dialout,audio asterisk

Run the following commands to set permissions:

$ 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


How to Start Asterisk ?

Run the following command to start the Asterisk service:

$ sudo systemctl start asterisk

You can Check connection Asterisk with the below command:

$ sudo asterisk -vvvr

To enable Asterisk service, run the command:

$ sudo systemctl enable asterisk


How to Configure Firewall for Asterisk?

By default, SIP uses UDP port 5060:

$ sudo ufw allow 5060/udp

Then run:

$ sudo ufw allow 10000:20000/udp


How to Enable Asterisk GUI ?

In order to access the Asterisk from the web browser, you will need to enable Asterisk GUI. First, edit the /etc/asterisk/http.conf file:

$ nano /etc/asterisk/http.conf

Uncomment and change the following lines:

enabled = yes
bindaddr = 0.0.0.0
bindport = 8088
prefix = asterisk
enable_static = yes
enablestatic = yes
redirect = / /static/config/index.html
uploads = /var/lib/asterisk/uploads/

Save and close the file then edit the /etc/asterisk/manager.conf file and set your admin user:

$ nano /etc/asterisk/manager.conf

Add / Modify the following lines:

enabled = yes
webenabled = yes
port = 5038
bindaddr = 0.0.0.0
[admin]
secret = admin1234
read = system,call,log,verbose,command,agent,user,config
write = system,call,log,verbose,command,agent,user,config,originate

Save and close the file when you are finished.

 

How to Install Asterisk GUI ?

Next, download the latest version of Asterisk GUI with the following command:

$ svn checkout http://svn.digium.com/svn/asterisk-gui/branches/2.0

Once downloaded, change the directory to downloaded directory and configure it with the following command:

$ cd 2.0/
$ ./configure

Next, build the Asterisk GUI with the following command:

$ make

You should get the following output:

+------- Asterisk-GUI Build Complete -------+
+ Asterisk-GUI has successfully been built, +
+ and can be installed by running:          +
+                                           +
+               make install                +
+-------------------------------------------+

Next, run the following command to install it to your system:

$ make install

You should see the following output:

+---- Asterisk GUI Installation Complete ---+
+                                           +
+    YOU MUST READ THE SECURITY DOCUMENT    +
+                                           +
+ Asterisk-GUI has successfully been        +
+ installed.      +
+                                           +
+-------------------------------------------+
+                                           +
+          BEFORE THE GUI WILL WORK         +
+                                           +
+ Before the GUI will run, you must perform +
+ some modifications to the Asterisk        +
+ configuration files in accordance with    +
+ the README file.  When done, you can      +
+ check your changes by doing:              +
+                                           +
+               make checkconfig            +
+                                           +
+-------------------------------------------+

Finally, restart the Asterisk service to apply the changes:

$ systemctl restart asterisk


How to Access Asterisk GUI ?

Now, open your web browser and access the Asterisk GUI using the URL http://your-server-ip:8088/asterisk/static/config/index.html. You will be redirected to the Asterisk Login page.

Then, Provide your admin username, password and click on the Login button. You should see the Asterisk GUI dashboard.


[Need assistance in installing any Open-source Software on your Linux system ? We can help you. ]


Conclusion

This article covers how to install Asterisk on Ubuntu 20.04. In fact, Asterisk is a free and open-source VoIP server used for building a VoIP telephony infrastructure for all sizes of organizations. Now, you can now connect your server to any PSTN network and start calling absolutely free.