How to install Asterisk on LINUX

Asterisk is a free, open-source framework for building communications applications and is sponsored by Sangoma.

Asterisk turns an ordinary computer into a communications server. Asterisk powers IP PBX systems, VoIP gateways, conference servers, and other custom solutions. It is used by small businesses, large businesses, call centers, carriers, and government agencies, worldwide.

What Can You Do With Asterisk?

Asterisk is a framework for building multi-protocol, real-time communications applications, and solutions. Asterisk is to real-time voice and video applications as Apache are to web applications: the underlying platform. Asterisk abstracts the complexities of communications protocols and technologies, allowing you to concentrate on creating innovative products and solutions.

At the moment, We are ready to install and configure Asterisk. Asterisk does not officially distribute packages for Linux distributions, so you’ll have to compile Asterisk from the source. While that task might sound daunting, the Asterisk maintainers have gone to great lengths to make this process as easy as possible. Here We will walk you through both buildings and start Asterisk. When you’re done, you will have a functioning Asterisk system that is ready for further configuration.

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 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 a 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:


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

Now Alls Done.

Leave a Reply