How to Install Asterisk on CentOS 8
Choose a different version or distribution
Introduction
Before we begin talking about how to install Asterisk on CentOS 8, let’s briefly understand – What Asterisk is?
Asterisk is a very famous and open-source PBX platform that powers IP PBX systems, conference servers, and VoIP gateways. It is being used worldwide by small businesses to huge enterprises.
It has many useful features like music on hold, call queuing, interactive voice response, conference calling, and voicemail.
In this tutorial, you will install Asterisk 20 on CentOS 8. We will also address some FAQs related to the Asterisk on CentOS 8.
Advantages
- Cost-effective: Asterisk is open-source, which means it’s free to use and can be modified to fit specific needs. This can make it an affordable alternative to commercial communication solutions.
- Flexibility: Asterisk can be integrated with a variety of technologies and programming languages, including PHP, Python, and Perl. This means developers can build a wide range of communication applications tailored to their specific needs.
- Customizability: Asterisk is highly customizable and can be configured to work with almost any type of telephony hardware or software. This makes it easy to integrate existing systems with new applications.
- Integration Capabilities: Asterisk can integrate with various third-party systems and technologies, enabling you to connect and interoperate with other communication platforms, databases, and applications.
- Community and Support: Asterisk benefits from a large and active community of developers and users who contribute to its development and provide support.
Prerequisites
- You have to be logged in as a user with sudo privileges.
- You also have to update CentOS 8 and install the development tools, as they will be helpful in compiling the Asterisk source code:
sudo yum update
sudo yum groupinstall core base "Development Tools"
Step 1 – Disable SELinux
Asterisk doesn't function properly if SELinux is set to the enforcing
mode.
In order to make Asterisk work, you'll have to open /etc/selinux/config
file and set SELINUX=disabled
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
Save the above file and reboot the system.
sudo shutdown -r now
On completion of the reboot, make sure getenforce
command returns Disabled
:
getenforce
Output
Disabled
Step 2 – Download Asterisk
1) We'll start by downloading Asterisk in the /usr/src
directory, which is a common place to keep source files.
2) Next, you need to change the /usr/src
directory by using the following command:
cd /usr/src/
3) With the following wget
command, download the latest version of Asterisk:
sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.tar.gz
4) Next, extract the downloaded file with the following command:
sudo tar zxf asterisk-20-current.tar.gz
5) Before continuing, change the Asterisk source directory with the help of the commands given below:
cd asterisk-20.*/
Step 3 – Install Asterisk Dependencies
1) Now, you've to download the Mp3 sources, required to build the Mp3 module and use the Mp3 files on Asterisk:
sudo contrib/scripts/get_mp3_source.sh
2) After that, you need to install all the missing dependencies with the help of install_prereq
script;
sudo contrib/scripts/install_prereq install
3) Once all the necessary packages are installed, the following output will be printed:
Output
#############################################
## install completed successfully
#############################################
Step 4 – Install Asterisk
This will be followed by the configure
script performing a number of checks to make sure all the dependencies needed for the build and install process are present, use the following command:
1) Use the configure
script as it will check if all the dependencies required by the build and install process are present or not, use the following command:
sudo ./configure --libdir=/usr/lib64 --with-jansson-bundled
On completion, you should be able to see the following output:
2) Now you've to select the modules you want to compile and install.
3) Majority of the modules have already been enabled, you can access the menuselect
with the following command:
sudo make menuselect
Since all Mp3 files have already been downloaded, you need to instruct Asterisk to build the Mp3 module by selecting format_mp3
:
4) Now hit F12
to save and exit, or simply switch to the Save and Exit
button, then press Enter
.
5) Use the make
command to commence the compilation process:
sudo make -j2
-j
flag as per the number of your processor cores.6) On completion, you will be presented with the following output:
7) Now, you need to install Asterisk and its module with the following command:
sudo make install
8) When the installation is complete, you'll see a similar output as below:
9) Now that Asterisk has been installed, you need to install the sample configuration files.
10) You can install the generic configuration files with the help of the following command:
sudo make samples
11) Alternatively, you can use the basic PBX configuration files:
sudo make basic-pbx
12) Install the Asterisk init script by typing the following command:
sudo make config
13) Now, run ldconfig
to update the shared libraries cache
sudo ldconfig
Step 5 – Creating Asterisk User
Asterisk runs as a root user but for security reasons, you will be creating a new system user and configuring Asterisk to run as the newly created user.
1) Use the command given below to create a new user named asterisk
sudo adduser --system --user-group --home-dir /var/lib/asterisk --no-create-home asterisk
2) In order to make the asterisk run as asterisk
user, open the /etc/sysconfig/asterisk
then simply uncomment the following two lines:
AST_USER="asterisk"
AST_GROUP="asterisk"
3) Next, you have to add asterisk
user to the dialout
and audio
groups
sudo usermod -a -G dialout,audio asterisk
4) Now, change the ownership and permissions of all asterisk files and directories so that the user asterisk can access those files.
sudo chown -R asterisk: /var/{lib,log,run,spool}/asterisk /usr/lib64/asterisk /etc/asterisk
sudo chmod -R 750 /var/{lib,log,run,spool}/asterisk /usr/lib64/asterisk /etc/asterisk
Step 6 – Start Asterisk
1) Now, you can start Asterisk with the following command:
sudo systemctl start asterisk
2) Connect to Asterisk Command Line Interface (CLI) in order to check for its proper functioning
sudo asterisk -vvvr
3) This is how the Asterisk CLI prompt will look like:
4) Now, enable the Asterisk service to start on boot with the following command:
sudo systemctl enable asterisk
Step 7 – Adjust the Firewall
Once Asterisk is installed successfully, configure the firewall to allow the traffic on specific ports.
2) Create the following Firewalld service by opening your text editor:
<?xml version="1.0" encoding="utf-8"?>
<service version="1.0">
<short>asterisk</short>
<description>Asterisk is a software implementation of a telephone private branch exchange (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>
3) With the next set of commands, Save and Apply the firewall rules:
sudo firewall-cmd --add-service=asterisk --permanent
sudo firewall-cmd --reload
3) Next, check whether the new firewall settings have been saved properly:
sudo firewall-cmd --list-all
Output
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: ssh dhcpv6-client asterisk
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
FAQs to Install Asterisk on CentOS 8
What is Asterisk?
Asterisk is an open-source framework used for building communication applications such as PBX systems, VoIP gateways, conference servers, and more.
What are the prerequisites for installing Asterisk on CentOS 8?
To install Asterisk on CentOS 8, you need a clean CentOS 8 installation, administrative access to the server, and a working internet connection.
How do I install Asterisk on CentOS 8?
The installation process for Asterisk on CentOS 8 involves downloading the source code, configuring the system, compiling the code, and installing the necessary packages.
Can I use Asterisk with existing telephony infrastructure?
Yes, Asterisk can integrate with existing telephony infrastructure, allowing you to bridge traditional telephony systems with modern VoIP systems.
What additional modules or packages can I install with Asterisk?
Asterisk offers numerous add-on modules and packages that extend its functionality. You can install modules for call recording, conferencing, video support, text-to-speech, and more to enhance your communication system.
What are the security considerations when deploying Asterisk?
When deploying Asterisk, it's important to follow best practices for securing your server and communication system.
Can I deploy Asterisk in a virtualized environment?
Yes, Asterisk can be deployed in a virtualized environment such as a virtual machine or a container.
Conclusion
We hope this detailed guide helped you understand how to install and configure Asterisk on CentOS 8 server. To learn more about Asterisk installation on CentOS 8, check out the official Asterisk installation Documentation.
If you have any queries, please leave a comment below, and we’ll be happy to respond to them for sure.