Red Hat / CentOS

How to Install Asterisk on CentOS 8/7

How to Install Asterisk on CentOS 8/7

How to Install Asterisk on CentOS 8/7

Asterisk is an open-source framework used for building communication applications. You can use it to turn a local computer or server to the communication server. It is used to power IP PBX systems, VoIP gateways, conference servers, and other solutions. It’s used by all kind of organizations worldwide and finally, but not last it is free and open source.

In this tutorial, we are going to show you how to install Asterisk on CentOS 8/7 (instructions also works on RHEL 8/7), but before we start, we will need to make some preparations so Asterisk can run smoothly after the installation.

Features of Asterisk PBX system

  • Conference calling
  • Call Recording
  • Call Monitoring
  • Distributed Universal Number Discovery
  • Caller ID on Call Waiting
  • Direct Inward System Access
  • Call Parking
  • SMS Messaging
  • Trunking
  • Transcoding
  • Voicemail
  • Call Queues and many other features.

How to Install Asterisk on CentOS 8/7

1. Disable SELinux on CentOS

To do this, SSH to your system and using your favorite command line text editor, open /etc/selinux/config and disable SELINUX.

# vim /etc/selinux/config

SELinux line should look like this:


How to Install Asterisk on CentOS 8/7

Now reboot your system. Once it comes back SSH again to that system.

Step 2: Install Required Packages

Asterisk has quite a few requirements that need to be installed. You can use the following yum command to install the required packages as shown.

# yum install -y epel-release dmidecode gcc-c++ ncurses-devel libxml2-devel make wget openssl-devel newt-devel kernel-devel sqlite-devel libuuid-devel gtk2-devel jansson-devel binutils-devel libedit libedit-devel

Before we continue further, create a new user with sudo privileges called “asterisk“, we will use this user to setup asterisk on the system.

# adduser asterisk -c "Asterisk User"
# passwd asterisk 
# usermod -aG wheel asterisk
# su asterisk

Next, install PJSIP, is a free open source multimedia communication library that implements standard based protocols such as SIP,SDP,RTP,STUN,TURN, and ICE. It is the Asterisk SIP channel driver that should improve the clarity of the calls.

To get the latest version, first let’s create a temporary directory where we will build the package from source.

$ mkdir ~/build && cd ~/build

Now go the PJSIP download page and grab the package or use the following wget command to download the package directly in the terminal.
Note that by the writing of this article the latest version is<2.10, this may change in future, thus make sure to use the latest version:

$ wget

Once the download is complete, extract the file and change to that directory.

$ tar -xvf 2.10.tar.gz
$ cd pjproject-2.10/

The next step is to prepare the package to be compiled. You can use the following command:

./configure CFLAGS="-DNDEBUG -DPJ_HAS_IPV6=1" --prefix=/usr --libdir=/usr/lib64 --enable-shared --disable-video --disable-sound --disable-opencore-amr

How to Install Asterisk on CentOS 8/7

You should not see any errors or warnings. Ensure that all dependencies are met:

$ make dep

How to Install Asterisk on CentOS 8/7

And now we can complete the install and link libraries with:

$ make && sudo make install && sudo ldconfig

Finally, ensure that all libraries are installed and present:

$ ldconfig -p | grep pj

You should get the following output:

3. Install Asterisk on CentOS 8/7

We are now ready to initiate the installation of Asterisk. Navigate back to our ~/build directory:

$ cd ~/build

Go to the Asterisk download page and grab the latest version or you can use the following wget command to download the file in terminal.

$ wget

By the writing of this tutorial, the latest Asterisk version is 17. Make sure that you are downloading the latest version of Asterisk, when you are following the steps.

Now extract the archive and navigate to the newly created directory:

$ tar -zxvf asterisk-17-current.tar.gz
$ cd asterisk-17.3.0/

This is the time to mention, that if you wish to enable mp3 support to play music while the client is on hold, you will need to install a few more dependencies. These steps are optional:

$ sudo yum install svn
$ sudo ./contrib/scripts/

After the second step, you should get output similar to these:

Start by running the configure script to prepare the package for compiling:

$ sudo contrib/scripts/install_prereq install
$ ./configure --libdir=/usr/lib64 --with-jansson-bundled

If you get any missing dependencies to install them. In my case, I got the following error:

configure: error: patch is required to configure bundled pjproject

To go around this simply run:

# yum install patch

And re-run the configure script. If all went perfectly without errors, you will see the following screenshot.

Now, let’s start the build process:

$ make menuselect

After a few seconds, you should get a list of features to enable:

If you attempt to use music on hold feature, you will need to enable the “format_mp3” feature from “Add-ons” section. Save your list and run the following command:

$ make && sudo make install

To install the sample configuration files, use the command below:

$ sudo make samples

To start Asterisk on boot, use:

$ sudo make config

Update the ownership of the following directories and files:

$ sudo chown asterisk. /var/run/asterisk
$ sudo chown asterisk. -R /etc/asterisk
$ sudo chown asterisk. -R /var/{lib,log,spool}/asterisk

Finally, let’s test our installation with:

$ sudo service asterisk start
$ sudo asterisk -rvv

You should see output similar to this one:

If you want to see a list of available commands type:

 errorhat*CLI> core show help 

To exit the Asterisk prompt, simply type:

errorhat*CLI> exit

Asterisk will still be running in the background.


Now you have a running Asterisk server and you can start connecting phones and extensions and adjust your configuration per your needs. For more details how to achieve this, it is recommended to use the Asterisk Wiki page. If you have any questions or comments, please let us know in the comment section below.

About the author

Jamie Vadym

Jamie Vadym

Founder of Error Hat. Expertise in Virtualization, Cloud Computing, Linux/UNIX systems, Programming,Storage systems,HA, Server Clustering e.t.c.


Click here to post a comment

  • Please help this error occurred:
    configure: error: *** Please install the ‘libedit’ development package.
    When I try to install libedit with “dnf install libedit-devel” I get the following message

    # dnf install libedit-devel
    Failed to set locale, defaulting to C
    CentOS-8 – AppStream 1.6 kB/s | 4.3 kB 00:02
    CentOS-8 – Base 1.5 kB/s | 3.9 kB 00:02
    CentOS-8 – Extras 269 B/s | 1.5 kB 00:05
    Extra Packages for Enterprise Linux 8 – x86_64 901 B/s | 5.4 kB 00:06
    No match for argument: libedit-devel
    Error: Unable to find a match

    Am I missing something here?
    Seems that this package is already installed, or does Asterisk means a diffrent package?

    Thank you