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.
1. Perform System Update
Run the below apt command to update the system's apt packages:
$ sudo apt update2. 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 -y3. 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-linuxNext, navigate to dahdi-linux and run the command:
$ cd dahdi-linux
$ sudo make
$ sudo make installNow, 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 modulesTo build LibPRI, execute:
$ cd /usr/src/
$ sudo git clone https://gerrit.asterisk.org/libpri libpri
$ cd libpri
$ sudo make
$ sudo make install4. 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-18Next, navigate to asterisk-18:
$ cd asterisk-18/Here, Download the MP3 sources:
$ sudo contrib/scripts/get_mp3_source.shRun the install_prereq script:
$ sudo contrib/scripts/install_prereq installType your ITU-T telephone code and press Ok.
Then run:
$ sudo ./configure
$ sudo make menuselectSelect format_mp3 and Save & Exit.
Start compiling with the command:
$ sudo make -j2Once done, install Asterisk:
$ sudo make installInstall either the generic configuration files:
$ sudo make samplesFinally, install the Asterisk init script:
$ sudo make configUpdate shared libraries cache:
$ sudo ldconfig5. 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" asteriskTo configure Asterisk, use the command:
$ nano /etc/default/asteriskThen, Add asterisk to the groups:
$ sudo usermod -a -G dialout,audio asteriskRun 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/asteriskRun the following command to start the Asterisk service:
$ sudo systemctl start asteriskYou can Check connection Asterisk with the below command:
$ sudo asterisk -vvvrTo enable Asterisk service, run the command:
$ sudo systemctl enable asteriskBy default, SIP uses UDP port 5060:
$ sudo ufw allow 5060/udpThen run:
$ sudo ufw allow 10000:20000/udpIn 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.confUncomment and change the following lines:
enabled = yesbindaddr = 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.confAdd / 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,originateSave and close the file when you are finished.
Next, download the latest version of Asterisk GUI with the following command:
$ svn checkout http://svn.digium.com/svn/asterisk-gui/branches/2.0Once downloaded, change the directory to downloaded directory and configure it with the following command:
$ cd 2.0/
$ ./configureNext, build the Asterisk GUI with the following command:
$ makeYou 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 installYou 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 asteriskNow, 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.
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.