How to install Asterisk 17 on CentOS 8

Asterisk is an open-source PBX software. It is used to manage SIP sessions between endpoints. It is a very powerful server that can be used to implement PBX, IVRs, VoIP gateways and many more features. It supports many VoIP protocols such as SIP(Session Initiation Protocol) and MGCP(Media Gateway Control Protocol. It also supports many hardware devices such as analogue cards, PRI cards, etc.

Today we will be installing Asterisk 17.1.0, which is the latest Asterisk release at the time of writing. It is the standard release meaning that it will receive regular updates which will focus more on new features and a little less on fixes. If you want a more stable framework we would recommend you to install Asterisk version with LTS(Long Term Support). They focus mainly on stability and user experience and not on the latest features that standard edition brings. Nonetheless, let us begin with the installation.

Step 1: Pre-requisites


To install Asterisk first we will make sure that our packages are up to date.

yum upgrade

We will now install the pre-requisite, the packages required for the compilation of Asterisk. But before we proceed with the packages we are first required to enable PowerTools repository which hosts many development packages.

dnf config-manager --set-enabled PowerTools  

Now we will install the required packages.

yum install -y wget gcc gcc-c++ make bzip2 patch libedit-devel uuid-devel libuuid-devel libxml2-devel sqlite sqlite-devel nano openssl openssl-devel

We should also disable SELinux so that it will not hinder with our installation process

nano /etc/selinux/config

Change the enforcing parameter to disabled.

Now save and exit the file. After a reboot, we will be good to go.

Next we will download the Asterisk 17 tarball from the official website, in /usr/src directory.

cd /usr/src/ && wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-17-current.tar.gz

Untar the tarball we just downloaded.

tar -xzvf asterisk-17-current.tar.gz

Note – If you want to compile Dahdi alongside asterisk then follow the optional dahdi installation steps before proceeding to the next steps.


Step 2: Configuration


Switch to the extracted directory. Here our version is 17.1.0. Yours might be different

cd asterisk-17.*

We will run the configure script to make sure that our system is ready for the build and to check for any missing dependencies.

./configure --with-jansson-bundled

We used the –with-jansson parameter so as to install Jansson library which is required for asterisk to work. It comes bundled with the asterisk source and saves us the hassle to compile it from the source.

The output should be similar as shown above. It will mean that our system is ready for Asterisk installation.

We will now select the modules and packages that we want to compile with our base Asterisk installation. Use the following command to open the asterisk configuration menu.

make menuselect
You should now see the menu as shown above. You can navigate using the arrow keys.

Note – If you have compiled Dahdi then make sure that chan_dahdi option is selected in the Channel Drivers menu


You can enable/disable the modules that you wish to compile alongside the core of asterisk in the above menu.

Step 3: Compiling


Now we will compile Asterisk with the modules that we have selected. This process will take some time depending on you operating system resources.

make && make install

Now we have installed Asterisk and will generate the sample configuration files for the Asterisk using the following command.

make samples

Also, we need to install asterisk init script

make config

Now to start asterisk service.

systemctl start asterisk

We will also make sure that asterisk will start on system boot

systemctl enable asterisk

To connect to the Asterisk CLI we will use the following command. Adding -vvv at the end will change the verbosity of the core logs to 3.

asterisk -rvvv

Note – if you have installed Dahdi as well, you can confirm if it is working by using the following command in the Asterisk CLI

dahdi show status

If for some reason the above command does not work, it is possible the asterisk didn’t load the dahdi module. To load the module use the following command and try the above command again.

module load chan_dahdi.so

Now asterisk is properly compiled and running. You can now start working on the config files to build your application. Asterisk usually stores all the config files under asterisk directory in /etc.

cd /etc/asterisk

Here you can see all the config files that will shape our asterisk application.

To stop asterisk service, we will connect to the asterisk CLI and use the following commands.

core stop now 
core stop gracefully 
core stop when convenient

core stop now – It will stop asterisk service immediately.

core stop gracefully– it will wait for any pending tasks to finish before stopping the asterisk service.

core stop when convenient – it does not prevent new tasks but allow them and will only stop the service when there is no activity.

Similarly, there are commands to restart Asterisk service as well.

core restart now
core restart gracefully 
core restart when convenient

They have functionality similar to the stop commands.


Optional: Installing Dahdi


DAHDI stands for Digium Asterisk Hardware Device Interface. As the name suggests it is the bundle which includes tools and drivers which are used to interface with a variety of telephone-related hardware. You can find the list of compatible hardware here.

We will first download the dahdi complete tarball from the official website. This tarball includes both the tools and drivers required for the DAHDI.

cd /usr/src && wget https://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz

Now we will untar the tarball we just downloaded

tar -xzvf dahdi-linux-complete-current.tar.*

Now switch to the extracted directory. Our version is 3.1.0. Yours might be different.

cd dahdi-linux-complete-3.1.0+3.1.0 

Before we start with the compilation process we first need to satisfy Dahdi’s dependencies.

First, we will get the required kernel sources and other packages.

yum install kernel-devel kernel-headers ncurses-devel libtermcap-devel newt-devel zlib-devel unixODBC-devel libtool

Reboot the system after using the above command to properly install kernel tools

We will also require elfutils libraries and utilities

dnf install elfutils-libelf-devel

Now by using the following commands we will compile the DAHDI source code and will move the files to the respective location for it to work properly.

make && make install && make install-config

You should see the result similar to as shown above. If you have Dahdi device connected, it will identify it and configure it.

Now we have to change the name of the sample config files since they have .sample extension. Switch to Dahdi folder

cd /etc/dahdi/

To edit the names you can use the following commands.

mv system.conf.sample system.conf 
mv modules.sample modules 
mv assigned-spans.conf.sample assigned-spans.conf
mv span-types.conf.sample span-types.conf 

Now we will use the following command to create links to the most recent shared libraries.

ldconfig

Once the config files are ready we can start the Dahdi service

systemctl start dahdi
systemctl enable dahdi

Now you have to compile the asterisk core. You can follow the steps starting from step 2: Configuration.


If you have any question or want to provide feedback please leave a comment in the comment section.

Leave a Reply

Your email address will not be published. Required fields are marked *