Asterisk is an open-source framework for building communications applications. Asterisk turns an ordinary computer into a communications server by powering IP PBX systems, VoIP gateways, conference servers and other custom solutions. Small businesses use it, large companies, call centres, carriers and government agencies, worldwide. Asterisk supports several standard voice-over IP protocols, including the Session Initiation Protocol (SIP), the Media Gateway Control Protocol (MGCP), and H.323.
In this guide, we will explain how to install Asterisk on a CentOS 7 server.
Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can quickly deploy your cloud servers.
Updating System Packages
It is always recommended that you update the system to the latest packages before beginning any significant installations. This is done with the command below:
sudo yum update
Step 1: Add SIP Ports to Config Server Firewall (CSF)
5061, both on TCP and UDP, are associated with the Session Initiation Protocol (SIP) by IANA. Hence, we will need to add these ports to our
You can read our guide on configuring CSF on Ubuntu and CentOS for more information on CSF.
sudo nano /etc/csf/csf.conf
Reload CSF to enforce our changes with the command below:
sudo csf -r
Depending on your needs, you may want to add other related ports:
MGCP - For users that require Media Gateway Control Protocol in their configuration
RTP - Real-Time Transport Protocol. You can make further changes in the
For users that want to use FreePBX (a web-based open-source GUI that controls and manages Asterisk:
For users that need IAX (Inter-Asterisk Exchange to allow multiple Asterisk servers to communicate with one another):
Ensure to reload CSF after making any changes.
Step 2: Install PJPROJECT
PJPROJECT is Asterisk’s SIP channel driver helping to improve call clarity and performance over older drivers. First, we need to install some build dependencies by issuing the command below:
sudo yum install epel-release gcc-c++ ncurses-devel libxml2-devel wget openssl-devel newt-devel kernel-devel-`uname -r` sqlite-devel libuuid-devel gtk2-devel jansson-devel binutils-devel bzip2 patch libedit libedit-devel
Next, create a working directory for the build then navigate to that directory:
sudo mkdir ~/build-asterisk cd ~/build-asterisk
Next, using the
wget tool, download the PJSIP driver source code:
sudo wget https://www.pjsip.org/release/2.8/pjproject-2.8.tar.bz2
Then proceed to extract it then navigate to the newly created directory:
sudo tar -jxvf pjproject-2.8.tar.bz2 cd pjproject-2.8
Next step is to specify the compiling flags and options by issuing the command below:
sudo ./configure CFLAGS="-DNDEBUG -DPJ_HAS_IPV6=1" --prefix=/usr --libdir=/usr/lib64 --enable-shared --disable-video --disable-sound --disable-opencore-amr
Next, ensure that all dependencies are in place by issuing the command below:
sudo make dep
make dep completes successfully, then build the plugin and install the packages by issuing the command below:
sudo make sudo make install sudo ldconfig
You can verify that the libraries are now installed by issuing the command below:
sudo ldconfig -p | grep pj
Step 3: Install Asterisk
Navigate to the build directory that we created earlier then download the latest version of Asterisk 16 by issuing the commands below:
cd ~/build-asterisk sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz
Next, extract the file before navigating to the new Asterisk directory, replacing
16.3.0 if needed:
sudo tar -zxvf asterisk-16-current.tar.gz cd asterisk-16.3.0
Enable MP3 Support
To use MP3 files for Music on Hold, install Subversion and run the configuration script:
sudo yum install svn sudo contrib/scripts/get_mp3_source.sh
Step 4: Configure and Build Asterisk
From the build directory for Asterisk, run the configure script to prepare the Asterisk source code for compiling:
./configure --libdir=/usr/lib64 --with-jansson-bundled
This will start the build process with a menu appearing shortly on screen, allowing you to configure the features you want to build.
sudo make menuselect
To use the MP3 format with Music on Hold, you should select
Add-Ons, navigating to
format_mp3 and selecting it. Select additional core sound packages and Music on Hold packages in the left menu, and enable
.wav format for your desired language. You can use
F12 to save and exit.
Next, compile Asterisk.
Lastly, we can now install Asterisk and install sample configuration files:
sudo make install sudo make samples
Configure Asterisk to start itself automatically on boot:
sudo make config
To test your Asterisk Connection, start Asterisk as shown below then proceed to connect to it:
sudo systemctl start asterisk sudo asterisk -rvv
To view a list of possible commands:
core show help
For more detailed instructions on configuring Asterisk, visit the Asterisk Project’s guide