Install Asterisk 18 with FreePBX on Rocky / AlmaLinux 9

In this blog post we will install Asterisk 18 with FreePBX on Rocky Linux / AlmaLinux 9. Asterisk is a free and open-source communication framework, used for building enterprise communication systems over the internet by turning a normal computer into a communication server. It has been used in creating massive call centers that span different regions and connect callers across the world. Asterisk powers IP PBX systems, VoIP gateways and conference servers to create VoIP systems. It comes with various features that will VoIP communication possible and as desired.

Features of Asterisk

Some of the features that makes Asterisk preferred for VoIP communication include:

  • Call Recording
  • Call Parking
  • SMS Messaging
  • Trunking
  • Transcoding
  • Conference calling
  • Distributed Universal Number Discovery
  • Caller ID on Call Waiting
  • Music on Hold
  • Music on Transfer
  • Automated Attendant
  • Voicemail
  • Authentication
  • Blacklists
  • Alarm receiver
  • Call Monitoring

Rocky Linux is a fork of CentOS, released after the end of support for CentOS 8. As such we are going to be using ‘dnf‘ as a package manager for our installation.

Step 1: Update system packages

Ensure to be running the latest system packages before beginning your installation. Also set SElinux in permissive mode to allow your installation. Use the below commands. Reboot the system once updated.

sudo dnf update

To set SElinux in permissive mode:

sudo setenforce 0
sudo sed -i 's/\(^SELINUX=\).*/\SELINUX=permissive/' /etc/selinux/config

Reboot your server:

sudo reboot

Step 2: Set System Timezone and Hostname

Next, we need to set the correct timezone for our system and also update hostname. Use the commands below to set timezone and hostname in the same order

sudo timedatectl set-timezone Africa/Nairobi
sudo hostnamectl set-hostname asterisk.example.com

Step 3: Add Epel Repository

We require to enable Epel repository as it might be useful on installation of packages. Run the command below:

sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm

Enable PowerTools on Rocky Linux 9:

sudo dnf config-manager --set-enabled crb

Install development tools using the commands below:

sudo yum group -y install "Development Tools"
sudo yum -y install initscripts git wget vim net-tools sqlite-devel psmisc ncurses-devel libtermcap-devel newt-devel libxml2-devel libtiff-devel gtk2-devel libtool libuuid-devel subversion kernel-devel crontabs cronie-anacron libedit libedit-devel

Step 4: Install Jansson

Jansson is a C Library required for media encoding and decoding. Download and install as below:

git clone https://github.com/akheron/jansson.git
cd jansson
autoreconf -i
./configure --prefix=/usr/
make
sudo make install

Step 5: Install PJSIP

PJSIP is an important communication library needed in the implementation of VoIP protocols such as SIP, TURN,ICE, SDP, RTP and STUN. We will build PJSIP from source as shown:

cd ~
git clone https://github.com/pjsip/pjproject.git
cd pjproject
./configure CFLAGS="-DNDEBUG -DPJ_HAS_IPV6=1" --prefix=/usr --libdir=/usr/lib64 --enable-shared --disable-video --disable-sound --disable-opencore-amr
make dep
make
sudo make install
sudo ldconfig

Step 6: Install Asterisk

Once all the dependencies have been installed, go ahead to download and install Asterisk.

cd ~
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz
tar xvfz asterisk-18-current.tar.gz
cd asterisk-18*/

Configure Asterisk.

./configure --libdir=/usr/lib64

You should see the below pattern on a successful configuration:

...
configure: creating ./config.status
config.status: creating makeopts
config.status: creating autoconfig.h
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 :

Step 7: Set Asterisk Menu Options

To set menu options, use the below command:

make menuselect

Make use of arrow keys and Enter key to select a desired option.


                              **************************************************
                                  Asterisk Module and Build Option Selection
                              **************************************************

                                       Press 'h' for help.

                              ---> Add-ons (See README-addons.txt)
                                   Applications
                                   Bridging Modules
                                   Call Detail Recording
                                   Channel Event Logging
                                   Channel Drivers
                                   Codec Translators
                                   Format Interpreters
                                   Dialplan Functions
                                   PBX Modules
                                   Resource Modules
                                   Test Modules
                                   Compiler Flags
                                   Utilities
                                   AGI Samples
                                   Core Sound Packages
                                   Music On Hold File Packages
                                   Extras Sound Packages

Select chan_ooh323 and format_mp3 under add-ons as shown:


                              **************************************************
                                  Asterisk Module and Build Option Selection
                              **************************************************

                                       Press 'h' for help.

                                       --- Extended ---
                                   XXX chan_mobile
                                   [*] chan_ooh323
                                   [*] format_mp3
                                   XXX res_config_mysql
                                       --- Deprecated ---
                                   XXX app_mysql
                                   XXX cdr_mysql


                              MP3 format [Any rate but 8000hz mono is optimal]

                              Support Level: extended

Next, select the different formats of audio packets under Core sound Packages:

                              **************************************************
                                  Asterisk Module and Build Option Selection
                              **************************************************

                                       Press 'h' for help.

                                       --- Core ---
                                   [*] CORE-SOUNDS-EN-WAV
                                   [*] CORE-SOUNDS-EN-ULAW
                                   [*] CORE-SOUNDS-EN-ALAW
                                   [*] CORE-SOUNDS-EN-GSM
                                   [*] CORE-SOUNDS-EN-G729
                                   [*] CORE-SOUNDS-EN-G722
                                   [ ] CORE-SOUNDS-EN-SLN16
                                   [ ] CORE-SOUNDS-EN-SIREN7
                                   [ ] CORE-SOUNDS-EN-SIREN14
                                   [ ] CORE-SOUNDS-EN_AU-WAV
                                   [ ] CORE-SOUNDS-EN_AU-ULAW
                                   [ ] CORE-SOUNDS-EN_AU-ALAW
                                   [ ] CORE-SOUNDS-EN_AU-GSM
                                   [ ] CORE-SOUNDS-EN_AU-G729
                                   [ ] CORE-SOUNDS-EN_AU-G722
                                   [ ] CORE-SOUNDS-EN_AU-SLN16
                                   [ ] CORE-SOUNDS-EN_AU-SIREN7
                                   [ ] CORE-SOUNDS-EN_AU-SIREN14
                                   [ ] CORE-SOUNDS-EN_GB-WAV
                                   [ ] CORE-SOUNDS-EN_GB-ULAW
                                   [ ] CORE-SOUNDS-EN_GB-ALAW
                                        ... More ...

                              English, G.722.1 (Siren7) format

                              Support Level: core

Next, head to music on hold and select the shown packages:

                              **************************************************
                                  Asterisk Module and Build Option Selection
                              **************************************************

                                       Press 'h' for help.

                                       --- Core ---
                                   [*] MOH-OPSOUND-WAV
                                   [*] MOH-OPSOUND-ULAW
                                   [*] MOH-OPSOUND-ALAW
                                   [*] MOH-OPSOUND-GSM
                                   [*] MOH-OPSOUND-G729
                                   [*] MOH-OPSOUND-G722
                                   [ ] MOH-OPSOUND-SLN16
                                   [ ] MOH-OPSOUND-SIREN7
                                   [ ] MOH-OPSOUND-SIREN14

                              opsound.org Music On Hold Files, GSM format

                              Support Level: core

Under Extra Sound Packages, choose the shown modules:

                              **************************************************
                                  Asterisk Module and Build Option Selection
                              **************************************************

                                       Press 'h' for help.

                                       --- Core ---
                                   [*] EXTRA-SOUNDS-EN-WAV
                                   [*] EXTRA-SOUNDS-EN-ULAW
                                   [*] EXTRA-SOUNDS-EN-ALAW
                                   [*] EXTRA-SOUNDS-EN-GSM
                                   [*] EXTRA-SOUNDS-EN-G729
                                   [*] EXTRA-SOUNDS-EN-G722
                                   [ ] EXTRA-SOUNDS-EN-SLN16
                                   [ ] EXTRA-SOUNDS-EN-SIREN7
                                   [ ] EXTRA-SOUNDS-EN-SIREN14
                                   [ ] EXTRA-SOUNDS-EN_GB-WAV
                                   [ ] EXTRA-SOUNDS-EN_GB-ULAW
                                   [ ] EXTRA-SOUNDS-EN_GB-ALAW
                                   [ ] EXTRA-SOUNDS-EN_GB-GSM
                                   [ ] EXTRA-SOUNDS-EN_GB-G729
                                   [ ] EXTRA-SOUNDS-EN_GB-G722
                                   [ ] EXTRA-SOUNDS-EN_GB-SLN16
                                   [ ] EXTRA-SOUNDS-EN_GB-SIREN7
                                   [ ] EXTRA-SOUNDS-EN_GB-SIREN14
                                   [ ] EXTRA-SOUNDS-FR-WAV
                                   [ ] EXTRA-SOUNDS-FR-ULAW
                                   [ ] EXTRA-SOUNDS-FR-ALAW
                                        ... More ...

                              English, G.729 format

                              Support Level: core

When done selecting all you need, Press X, to Save & Quit and save your configuration.


                              **************************************************
                                  Asterisk Module and Build Option Selection
                              **************************************************

                                       Press 'h' for help.

                                        scroll              => up/down arrows
                                        toggle selection    => Enter
                                        select              => y
                                        deselect            => n
                                        select all          => F8
                                        deselect all        => F7
                                        back                => left arrow
                                        quit                => q
                                        save and quit       => x

                                        XXX means dependencies have not been met
                                            or a conflict exists

                                        < > means a dependency has been deselected
                                            and will be automatically re-selected
                                            if this item is selected

                                        ( ) means a conflicting item has been
                                            selected

Step 8: Build and install Asterisk

Install Asterisk dependencies using install_prereq script:

sudo ./contrib/scripts/install_prereq install

Sample Output:

Complete!
#############################################
## install completed successfully
#############################################
[root@asterisk asterisk-18.26.0]#

First download mp3 decoder into source tree with the below command:

[root@asterisk asterisk-18.26.0]# ./contrib/scripts/get_mp3_source.sh
A    addons/mp3
A    addons/mp3/layer3.c
A    addons/mp3/interface.c
A    addons/mp3/MPGLIB_TODO
A    addons/mp3/mpg123.h
A    addons/mp3/mpglib.h
A    addons/mp3/decode_ntom.c
A    addons/mp3/MPGLIB_README
A    addons/mp3/common.c
A    addons/mp3/huffman.h
A    addons/mp3/tabinit.c
A    addons/mp3/Makefile
A    addons/mp3/README
A    addons/mp3/decode_i386.c
A    addons/mp3/dct64_i386.c
Exported revision 204.
[root@asterisk asterisk-18.26.0]#

Then build and install Asterisk as below:

make
sudo make install
make basic-pbx
sudo make config
sudo ldconfig

Sample Output:

[root@asterisk asterisk-18.26.0]# make
...
Building Documentation For: channels pbx apps codecs formats cdr cel bridges funcs tests main res addons
 +--------- Asterisk Build Complete ---------+
 + Asterisk has successfully been built, and +
 + can be installed by running:              +
 +                                           +
 +                make install               +
 +-------------------------------------------+
[root@asterisk asterisk-18.26.0]# sudo make install 
...
 +---- 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    +
 +-------------------------------------------+

Step 9: Configure Asterisk

We are going to create a separate user to run asterisk as below:

sudo groupadd asterisk
sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk
sudo usermod -aG audio,dialout asterisk
sudo chown -R asterisk.asterisk /etc/asterisk /var/{lib,log,spool}/asterisk /usr/lib64/asterisk

Set the default user for Asterisk to asterisk. Open the configuration files below and uncomment the lines as shown:

$ sudo vim /etc/sysconfig/asterisk
AST_USER="asterisk"
AST_GROUP="asterisk"

$ sudo vim /etc/asterisk/asterisk.conf
runuser = asterisk ; The user to run as.
rungroup = asterisk ; The group to run as.

Once you save the changes, restart asterisk and enable it to start on system reboot.

sudo systemctl restart asterisk
sudo systemctl enable asterisk

Confirm the status of Asterisk service:

sudo systemctl status asterisk

The output should saw that it is running as below:

[root@asterisk asterisk-18.26.0]# sudo systemctl status asterisk
● asterisk.service - LSB: Asterisk PBX
     Loaded: loaded (/etc/rc.d/init.d/asterisk; generated)
     Active: active (running) since Tue 2024-12-24 22:07:27 EAT; 5min ago
       Docs: man:systemd-sysv-generator(8)
    Process: 98257 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS)
   Main PID: 98289 (asterisk)
      Tasks: 37 (limit: 35884)
     Memory: 55.1M
        CPU: 2.050s
     CGroup: /system.slice/asterisk.service
             ├─98284 /bin/sh /usr/sbin/safe_asterisk
             └─98289 /usr/sbin/asterisk -f -vvvg -c

Dec 24 22:07:27 asterisk.cloudspinx.com systemd[1]: Starting LSB: Asterisk PBX...
Dec 24 22:07:27 asterisk.cloudspinx.com asterisk[98257]: Starting asterisk:

Access Asterisk command prompt to confirm that it is working

sudo asterisk -rvv

This should take you to Asterisk command prompt as shown in the output below:

Asterisk 18.26.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <[email protected]>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Running as user 'asterisk'
Running under group 'asterisk'
Connected to Asterisk 18.26.0 currently running on asterisk (pid = 98289)
asterisk*CLI>

Check service uptime:

core show uptime

To exit the terminal type exit command:

asterisk*CLI> exit
Asterisk cleanly ending (0).
Executing last minute cleanups

This shows that Asterisk is properly installed and working as expected. Up to this point, therefore, you have successfully installed Asterisk 18 LTS on Rocky Linux / AlmaLinux 9 and you can begin using it.

Explore More with CloudSpinx

Looking to streamline your tech stack? At CloudSpinx, we deliver robust solutions tailored to your needs.

Check out our next article:

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

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

Related Post

PHP is a recursive acronym that stands for Hypertext Processor. It is a popular general-purpose scripting language used in web […]

We previously installed Asterisk LTS 18 on Rocky Linux 9 and we saw that it can only be administered from […]

How can one install Zabbix Server 7.2 on Rocky Linux 9 / AlmaLinux 9?. Zabbix is an open source monitoring […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.