Oct 31, 2019 How to Install Asterisk on CentOS 7. Asterisk is an open source framework used for building communication applications. You can use it to turn a local computer or server to communication server. It is used to power IP PBX systems, VoIP gateways, conference servers and other solutions. Feb 24, 2017 Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Updated by LinodeContributed by Nick Rahl
Try this guide to receive $20 at signup on a new account.
Contribute on GitHubReport an Issue | View File | Edit File
Dedicated CPU instances are available!Linode's Dedicated CPU instances are ideal for CPU-intensive workloads like those discussed in this guide. To learn more about Dedicated CPU, read our blog post. To upgrade an existing Linode to a Dedicated CPU instance, review the Resizing a Linode guide.
What is Asterisk?
Asterisk is an open source private branch exchange (PBX) server that uses Session Initiation Protocol (SIP) to route and manage telephone calls. Notable features include customer service queues, music on hold, conference calling, and call recording, among others.
This guide covers the steps necessary to provision a new CentOS 7 Linode as a dedicated Asterisk server for your home or office.
Note
This guide is written for a non-root user. Commands that require elevated privileges are prefixed with
sudo
. If you’re not familiar with the sudo
command, you can check our Users and Groups guide.Before You Begin
- Create a CentOS 7 Linode in your closest data center (barring Atlanta (us-southeast), which does not currently support SIP servers). A 2GB Linode is enough to handle 10-20 concurrent calls using a non-compressed codec, depending on the processing required on each channel.
- Ensure you have followed the Getting Started and Securing Your Server guides to prepare your Linode. Do not complete the steps to set up a firewall.
- Update your system:
- Disable SELinux and reboot your Linode. If you have Lassie enabled, your Linode will be back up and running in a few minutes.
Configure firewalld
- CentOS 7 enables firewalld’s
public
zone for the default interface (eth0
). SSH and DHCPv6 services are also enabled by default. To verify your current firewalld zone:That should return:And: - Add the SIP services.
Note
All the following firewalld rules contain the--permanent
flag to ensure the rules persist after a system reboot. - Depending on your needs, you may want to add other related ports:
- MGCP - If you use media gateway control protocol in your configuration.
- RTP - The media stream - you can change this in
/etc/asterisk/rtp.conf
. - If you plan to use FreePBX to manage Asterisk, add the following rule:
- IAX - If you need IAX, add the following rule. IAX is “Inter-Asterisk Exchange” and was meant to allow multiple Asterisk servers to communicate with one another. Some VOIP trunking providers use this, but most use SIP. Unless your VOIP provider requires it or you are running multiple Asterisk servers, you probably won’t need IAX or IAX2.
- Verify your new configuration with:You should see the services and ports you just added in addition to default SSH and DCHPv6 services:
Install PJPROJECT
PJPROJECT is Asterisk’s SIP channel driver. It should improve call clarity and performance over older drivers.
- Install build dependencies:
- As a non-root user, create a working directory for the build:
- Change to that directory:
- Use
wget
to download the PJSIP driver source code: - Extract it:
- Change to the newly created directory:
- Specify the compiling flags and options:
- Ensure that all dependencies are in place:
- If
make dep
completes successfully, then build the plugin. It should only take a few minutes. - Install the packages:
- Ensure the libraries have been properly installed:You should see:
Install Asterisk
- Return to your build directory:
- Download the latest version of Asterisk 16:
- Untar the file:
- Switch to the new Asterisk directory, replacing
16.1.1
if needed:
Enable MP3 Support
- To use MP3 files for Music on Hold, install Subversion:
- Run the configuration script:
Configure and Build Asterisk
- In your build directory for Asterisk, run the
configure
script to prepare the Asterisk source code for compiling: - Start the build process. After a short while, you should see a menu on screen allowing you to configure the features you want to build. This also produces generic binaries instead of native architecture optimized binaries.
- If you want to use the MP3 format with Music on Hold, you should select
Add-Ons
, then use the right arrow to move to the right-hand list. Navigate toformat_mp3
and press Enter to select it. - Select additional core sound packages and Music on Hold packages in the left menu, and enable
.wav
format for your desired language (ie. use theEN
package for English.). - Press F12 to save and exit.
- Compile Asterisk. When finished, you should see a message which says Asterisk has successfully been built.
- Install Asterisk:
- Install sample configuration files:
- Configure Asterisk to start itself automatically on boot:
Test Connection
You now have a working Asterisk phone server. Fire up Asterisk and make sure it runs.
- Start Asterisk:
- To ensure that asterisk service starts even after a reboot, enable the service:
- Connect to Asterisk:You should see an output similar to the following:
- To see a list of possible commands:
- To disconnect type:Once disconnected, Asterisk continues to run in the background.
Next Steps
Now that you have an Asterisk server running on your Linode, it’s time to connect some phones, add extensions, and configure the various options that are available with Asterisk. For detailed instructions, check out the Asterisk Project’s guide to Configuring Asterisk.
CautionWhen running a phone system on a remote server such as a Linode, it’s always good practice to secure the signaling data with TLS and the audio portion of calls using SRTP to prevent eavesdropping. Once you have a working dial-plan, be sure to follow the Secure Calling Guide to encrypt your communications.
Join our Community
Please enable JavaScript to view the comments powered by Disqus.comments powered by Disqus
This guide is published under a CC BY-ND 4.0 license.