How To Set up Asterisk on CentOS 7

Asterisk is the preferred and broadly adopted open supply PBX platform that powers IP PBX programs, convention servers and VoIP gateways. It’s utilized by people, small companies, massive enterprises and governments worldwide.

Asterisk options embody voicemail, music on maintain, convention calling, name queuing, name recording, interactive voice response and rather more.

This tutorial will information you thru the steps required to put in Asterisk 15 on CentOS 7.

Conditions

  • Earlier than persevering with with this tutorial, be sure to are logged in as a person with sudo privileges.

  • Replace your CentOS system and set up the event instruments which are required to compile Asterisk supply code:

    sudo yum replace
    sudo yum groupinstall core base “Improvement Instruments”

Disable Selinux

If SELinux is about to implementing mode, Asterisk is not going to perform accurately.

To disable SELinux safety features, open the /and so forth/selinux/config file and set SELINUX=disabled

/and so forth/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one in all these three values:
# implementing – SELinux safety coverage is enforced.
# permissive – SELinux prints warnings as an alternative of implementing.
# disabled – No SELinux coverage is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one in all these two values:
# focused – Focused processes are protected,
# mls – Multi Degree Safety safety.
SELINUXTYPE=focused

Save the file and reboot your CentOS system with:

As soon as the machine boots up, ensure that the getenforce command returns Disabled:

Obtain Asterisk

We’re going to obtain Asterisk supply within the /usr/src listing which is the widespread location to put supply recordsdata.

Change to the /usr/src listing by typing:

Obtain the most recent model of Asterisk 15 with the next wget command:

sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-15-current.tar.gz

As soon as the obtain is accomplished, extract the downloaded file utilizing the next command:

sudo tar zxf asterisk-15-current.tar.gz

Earlier than persevering with with the following steps, be sure to change to the Asterisk supply listing by typing:

Set up Asterisk Dependencies

Obtain the MP3 sources that are required to construct the MP3 module and use MP3 recordsdata on Asterisk:

sudo contrib/scripts/get_mp3_source.sh

Subsequent set up all lacking dependencies with the install_prereq script:

sudo contrib/scripts/install_prereq set up

The script will set up all obligatory packages and upon profitable completion, it is going to print the next message:

#############################################
## set up accomplished efficiently
#############################################

Set up Asterisk

The configure script will carry out various checks to ensure all the dependencies which are required by the construct and set up course of are current, begin the script by typing:

sudo ./configure –libdir=/usr/lib64

Upon profitable completion, you will notice the next output:

The following step is to pick the modules you wish to compile and set up.

A lot of the modules are already enabled. Entry the Menuselect system, by typing:

We now have already downloaded the MP3 supply recordsdata and now we have to inform Asterisk to construct the MP3 module by deciding on format_mp3:

As soon as you might be achieved, press F12 to save lots of and exit, or swap to the Save and Exit button and press Enter.

Begin the compilation course of utilizing the make command:

The construct might take a while to finish, relying in your system. You may modify the -j flag in accordance the variety of cores your processor.

As soon as the construct course of is accomplished, you’ll be offered with the next message:

The following step is to put in Asterisk and its modules by typing:

As soon as the set up is completed the script will show the next message:

Now that the Asterisk is put in we have to set up the pattern configuration recordsdata.

Set up both the generic configuration recordsdata with reference documentation by typing:

Or set up the fundamental PBX configuration recordsdata:

The final step is to put in the Asterisk init script by typing:

Lastly run ldconfig to replace the shared libraries cache:

Create Asterisk Consumer

By default Asterisk runs as a root person. For safety causes we’ll create a brand new system person and configure Asterisk to run because the newly created person.

To create a brand new system person named asterisk run the next command:

sudo adduser –system –user-group –home-dir /var/lib/asterisk –no-create-home asterisk

To configure Asterisk to run as asterisk person, open the /and so forth/sysconfig/asterisk file and uncomment the next two traces:

/and so forth/sysconfig/asterisk

AST_USER=”asterisk”
AST_GROUP=”asterisk”

Add the asterisk person to the dialout and audio teams:

sudo usermod -a -G dialout,audio asterisk

We additionally must change the possession and permissions of all asterisk recordsdata and directories so the person asterisk can entry these recordsdata:

sudo chown -R asterisk: /var//asterisk /usr/lib64/asterisk /and so forth/asterisk
sudo chmod -R 750 /var//asterisk /usr/lib64/asterisk /and so forth/asterisk

Begin Asterisk

Now that we’re all arrange, we are able to begin the Asterisk service with the next command:

sudo systemctl begin asterisk

To confirm that Asterisk is working, connect with the Asterisk command line interface (CLI) by typing:

You’ll see the default Asterisk CLI immediate:

The final step is to allow Asterisk service to start out on boot with:

sudo systemctl allow asterisk

Alter the Firewall Guidelines

Now that Asterisk is put in and working you could configure your firewall to permit visitors on Asterisk particular ports.

In the event you don’t have firewall enabled in your system, you possibly can skip this part.

Open your textual content editor of alternative and create the next Firewalld service:

/and so forth/firewalld/providers/asterisk.xml

<?xml model=”1.0″ encoding=”utf-8″?>
<service model=”1.0″>
<quick>asterisk</quick>
<description>Asterisk is a software program implementation of a phone personal department trade (PBX).</description>
<port protocol=”udp” port=”10000-10100″/>
<port protocol=”udp” port=”4569″/>
<port protocol=”udp” port=”2727″/>
<port protocol=”udp” port=”5060-5061″/>
</service>

Save the file and apply the brand new firewall guidelines by typing:

sudo firewall-cmd –add-service=asterisk –permanent
sudo firewall-cmd –reload

Lastly verify if the brand new firewall guidelines are utilized efficiently with:

sudo firewall-cmd –list-allpublic (lively)
goal: default
icmp-block-inversion: no
interfaces: eth0
sources:
providers: ssh dhcpv6-client asterisk
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
wealthy guidelines:

Be at liberty to regulate the firewall in accordance with your want.

Conclusion

On this information we’ve proven you the way to set up the most recent Asterisk model from supply in your CentOS system.

It’s best to now verify the Asterisk Documentation and study extra about the way to configure and use Asterisk.

In the event you hit an issue or have suggestions, go away a remark beneath.

Supply

Germany Devoted Server

Leave a Reply