This article will describe how to install the open source communication software Asterisk on RHEL 8 / CentOS 8; due to the fact that Asterisk and other important dependencies are not available as RPM packages from the repositories, it is needed to compile them from sources.
In this tutorial you will learn:
- Which are the pre-requisites to install Asterisk
- How to compile Asterisk from sources
- How to start Asterisk
- How to reconfigure or remove Asterisk
- How to access Asterisk command line interface
Software Requirements and Conventions Used
|Category||Requirements, Conventions or Software Version Used|
|System||RHEL 8 / CentOS 8|
|Software||Asterisk, pjsip, libedit|
|Other||local or remote repositories configured; correct system date and timezone.|
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Asterisk is an open source private branch exchange (PBX) software, and as such its main purpose is to establish and control telephone calls between various systems, through traditional PSTN lines or modern VoIP endpoints.
In this guide we will make sure it will be installed in RHEL 8 / CentOS 8 along with common components.
Installing Asterisk on RHEL 8 / CentOS 8 – step by step.
We will put the last version – the 16.3.0 at the time of writing this tutorial.
We need to install the below packages including
systemd-develif we want to start Asterisk as a systemd service.
# dnf -y install wget bzip2 tar sqlite-devel ncurses-devel systemd-devel
And to develop from sources:
# dnf -y install binutils gcc gcc-c++ kernel-devel autoconf automake libtool
From now on we need to install everything from sources so let’s do it from a common folder
# mkdir -p /root/src && cd /root/src
First we are going to compile
libedit, a replacement or alternative to the GNU readline command-line editing.
# cd /root/src # wget http://thrysoee.dk/editline/libedit-20190324-3.1.tar.gz # tar xzvf libedit-20190324-3.1.tar.gz # cd libedit-20190324-3.1 # ./configure && make && make install
- Installing optional components
The following components are optional, but in a real scenario are very often needed.
DAHDI(Digium/Asterisk Hardware Device Interface): it is a framework for interfacing with digital telephony cards in Asterisk.
Let’s install it.
# cd /root/src # wget https://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz # tar zxvf dahdi-linux-complete-current.tar.gz && cd dahdi-linux-complete-3.0.0+3.0.0 # make all && make install && make install-config # cd /etc/dahdi && cp system.conf.sample system.conf # systemctl enable dahdi && systemctl start dahdi # modprobe dahdi # modprobe dahdi_transcode
LibPRI is a library that adds support for ISDN (PRI and BRI), basically is needed if installing an ISDN card to communicate with legacy systems.
To install it:
# cd /root/src/ # wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.6.0.tar.gz # tar xzvf libpri-1.6.0 && cd libpri-1.6.0 # make && make install
- Installing Asterisk
Now it’s time to compile the main application from sources – as mentioned.
This will install also the SIP library
pjsipinto the system.
# cd /root/src/ # wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16.3.0.tar.gz # tar xzvf asterisk-16.3.0.tar.gz # wget https://raw.githubusercontent.com/asterisk/third-party/master/pjproject/2.8/pjproject-2.8.tar.bz2 # mv pjproject-2.8.tar.bz2 /tmp # cd asterisk-16.3.0 # ./configure # make && make install && make install-logrotate
make install-logrotatewe make sure the application log files will be rotated.
- Configuring Asterisk
In Asterisk there are many configuration files, the main is
asterisk.conf; to install a default version of all of them we need to run:
# cd /root/src/asterisk-16.3.0/ # make samples
At this point, since some modules or features requires further configuration or dependencies, it is better to disable them.
However, this is not mandatory, they are not essential components preventing Asterisk from starting.
#cd /etc/asterisk # cp modules.conf modules.conf.org # echo "noload => res_config_ldap.so" >>modules.conf # echo "noload => res_pjsip_transport_websocket.so" >>modules.conf # echo "noload => cdr_sqlite3_custom.so" >>modules.conf # echo "noload => cel_sqlite3_custom.so" >>modules.conf # echo "noload => res_config_sqlite3.so" >>modules.conf # echo "noload => cdr_pgsql.so" >>modules.conf # echo "noload => cel_pgsql.so" >>modules.conf # echo "noload => res_config_pgsql.so" >>modules.conf sed -i.org 's/enabled = yes/enabled = no/' ari.conf
Afterwards it`s time to prepare the systemd service files:
# cd /root/src/asterisk-16.3.0/contrib/systemd # cp asterisk* /usr/lib/systemd/system
The Asterisk service should run as a normal user, for security reasons, so we need to add a service ID that will be called
asteriskas specified in the systemd config file.
# useradd -m -c "asterisk user"
Then let’s change some permissions:
chown -R asterisk:asterisk /var/log/asterisk/* chown asterisk:asterisk /var/log/asterisk/.
- Starting Asterisk
SELinux will prevent Asterisk from starting, so we are putting it in
permissive modefor the sake of simplicity.
# setenforce 0 # sed -i.org 's/enforcing/permissive/' /etc/sysconfig/selinux
Finally we can start Asterisk
# systemctl enable asterisk # systemctl start asterisk
You can also run Asterisk directly without systemd by issuing:
# /usr/sbin/asterisk -mqf -C /etc/asterisk/asterisk.conf
# asterisk -vvvc
to get verbose info.
- Reconfiguring Asterisk
It is possible at any time to reconfigure Astering by removing or (re-)adding any feature.
Just stop the service, change to the source folder and run
# systemctl stop asterisk # cd /root/src/asterisk-16.3.0/ # make menuselect
If you have made any change you need to save the configuration before exiting from the menu-select menu.
After is necessary to re-compile again Asterisk as explained above. It is better to make any change in a test environment first.
- Removing Asterik
If you ever need to remove Asterisk from the system – including Dahdi and libpri – here are the steps:
# systemctl stop dahdi # systemctl stop asterisk # cd /root/src/asterisk-16.3.0 # make uninstall-all cd /root/src/libpri-1.6.0 && make uninstall
- Accessing Asterisk CLI
This software has also its shell, in order to access it – once Asterisk is started – we need to type:
# asterisk -r
We have successfully compiled Asterisk from sources and started it, however it is not enough to get a working environment; typically after installation you will add your SIP endpoints by editing the configuration file
sip.conf – or through the CLI mentioned – and configure any extension in the file
extensions.conf. Both files are in /etc/asterisk.