Now that you understand the fundamentals of VoIP and the Asterisk platform, you are ready to install and configure Asterisk. At the moment, Asterisk does not officially distribute packages for Linux distributions, so you’ll have to compile Asterisk from source. While that task might sound daunting, the Asterisk maintainers have gone through great lengths to make this process as easy as possible. This article will walk you through both building and starting Asterisk. When you’re done, you will have a functioning Asterisk system that is ready for further configuration.
Note: The instructions below are current as of the time that this was written. I recommend that you always consult the official installation instructions to ensure that you are following the latest recommended procedures.
Building and installing Asterisk
The first step is to download and unzip a current release of Asterisk. You should consult the Asterisk version documentation when making a decision, but generally, you will want to use the latest LTS version. Asterisk versions can be downloaded from the Asterisk website. I use Asterisk 16.6.1 in this tutorial, but the instructions will generally be the same for other versions.
I used /usr/local/src
as the base directory to download the source code into:
[root@asterisk-1 ~]# wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz
[root@asterisk-1 src]# tar -xf asterisk-16-current.tar.gz
[root@asterisk-1 src]# cd asterisk-16.6.1/
You’re now ready to install the prerequisites needed to build and run Asterisk. The Asterisk team has made this process as easy as possible by providing an install_prereq
script to automatically install the needed dependencies based on your distribution. Below, I’ve run the script in "test" mode, which helpfully prints the exact command you need to run to install dependencies. I then ran the script in "install" mode to actually install the dependencies that are needed:
[root@asterisk-1 asterisk-16.6.1]# cd scripts
[root@asterisk-1 scripts]# ./install_prereq test
#############################################
## test: test mode.
## Use the commands here to install your system.
#############################################
yum install --skip-broken --assumeyes gcc-c++ libedit-devel jansson-devel libuuid-devel sqlite-devel libxml2-devel speex-devel speexdsp-devel libogg-devel libvorbis-devel alsa-lib-devel portaudio-devel libcurl-devel xmlstarlet bison flex postgresql-devel unixODBC-devel neon-devel gmime-devel lua-devel uriparser-devel libxslt-devel openssl-devel mysql-devel bluez-libs-devel radcli-devel freetds-devel jack-audio-connection-kit-devel net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libical-devel spandsp-devel libresample-devel uw-imap-devel binutils-devel libsrtp-devel gsm-devel doxygen graphviz zlib-devel openldap-devel hoard codec2-devel fftw-devel libsndfile-devel unbound-devel subversion bzip2 patch python-devel
[root@asterisk-1 scripts]# ./install_prereq install
Now that the prerequisites have been installed, you can run the configure scripts in preparation for building Asterisk. On my system, I had to install using the bundled version of libjansson
, as the version in the repositories was too old. This command below will run configure scripts for Asterisk:
[root@asterisk-1 asterisk-16.6.1]# ./configure --with-jansson-bundled
By default, Asterisk uses the menuselect
utility to present you with a graphical list of configuration options. Take the time to review these to get a sense of the many modules and options available in an Asterisk installation:
In my case, I left all of the options the same with one exception: I unselected the chan_sip module in the Channel Drivers menu. The chan_sip module is an older, deprecated SIP channel driver, and you won’t need it in a modern Asterisk environment.
With the configuration script run, you’re ready to build Asterisk from source using make
. I’ve shortened the output below to save space, but once make
is done running, you will see a success prompt and instructions to run the installation:
[root@asterisk-1 asterisk-16.6.1]# make
[CC] astcanary.c -> astcanary.o
[LD] astcanary.o -> astcanary
[CC] astdb2sqlite3.c -> astdb2sqlite3.o
[CC] hash/hash.c -> hash/hash.o
[CC] hash/hash_bigkey.c -> hash/hash_bigkey.o
[CC] hash/hash_buf.c -> ha
...
Building Documentation For: third-party 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 +
+-------------------------------------------+
Once the build has completed, you are ready to install Asterisk. As the prompt suggests, this task is easy: Just run make install
. I also recommend running make samples
(to generate config file samples) and make config
(to generate systemd
unit files). Again, I have shortened the output below for brevity:
[root@asterisk-1 asterisk-16.6.1]# 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 +
+-------------------------------------------+
[root@asterisk-1 asterisk-16.6.1]# make samples
[root@asterisk-1 asterisk-16.6.1]# make config
Finally, I found that I had to restore the SELinux context on a few files used by Asterisk in my environment. To do so, I used the commands below:
[root@asterisk-1 asterisk-16.6.1]# restorecon -v /var/lib/asterisk/astdb.sqlite3
[root@asterisk-1 asterisk-16.6.1]# restorecon -rv /var/lib/asterisk/
[root@asterisk-1 asterisk-16.6.1]# restorecon -rv /etc/asterisk/
Note: You might find that additional SELinux tuning is needed in your environment, which is beyond the scope of this article (< if we have an selinux enable sysadmin article, link to it here>). [Note: Add link.]
Congratulations! Asterisk has now been installed and you’re ready to begin configuration. You can now verify your installation by starting the Asterisk service and connecting via the command line as seen below. Be sure to stop the service when you’re done since you won’t have any configuration in place until we set up phones in this series’ next article:
[root@asterisk-1 ~]# systemctl start asterisk
[root@asterisk-1 ~]# asterisk -r
Asterisk 16.6.1, Copyright (C) 1999 - 2018, Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
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.
=========================================================================
Connected to Asterisk 16.6.1 currently running on asterisk-1 (pid = 22082)
asterisk-1*CLI> quit
Asterisk cleanly ending (0).
Executing last minute cleanups
[root@asterisk-1 ~]# systemctl stop asterisk
Wrapping up
In this article, you learned how to build and install Asterisk from source. Thanks to the efforts of the Asterisk project, this is a simple and painless experience. You are now ready to begin configuring Asterisk in the next article of this series.
About the author
Anthony Critelli is a Linux systems engineer with interests in automation, containerization, tracing, and performance. He started his professional career as a network engineer and eventually made the switch to the Linux systems side of IT. He holds a B.S. and an M.S. from the Rochester Institute of Technology.
Browse by channel
Automation
The latest on IT automation for tech, teams, and environments
Artificial intelligence
Updates on the platforms that free customers to run AI workloads anywhere
Open hybrid cloud
Explore how we build a more flexible future with hybrid cloud
Security
The latest on how we reduce risks across environments and technologies
Edge computing
Updates on the platforms that simplify operations at the edge
Infrastructure
The latest on the world’s leading enterprise Linux platform
Applications
Inside our solutions to the toughest application challenges
Original shows
Entertaining stories from the makers and leaders in enterprise tech
Products
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud services
- See all products
Tools
- Training and certification
- My account
- Customer support
- Developer resources
- Find a partner
- Red Hat Ecosystem Catalog
- Red Hat value calculator
- Documentation
Try, buy, & sell
Communicate
About Red Hat
We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.
Select a language
Red Hat legal and privacy links
- About Red Hat
- Jobs
- Events
- Locations
- Contact Red Hat
- Red Hat Blog
- Diversity, equity, and inclusion
- Cool Stuff Store
- Red Hat Summit