How To Install Asterisk On CentOS 7
This tutorial will guide you through the steps required to install Asterisk 15 on CentOS 7.
If SELinux is set to enforcing mode, Asterisk will not function correctly.
To disable SELinux security features, open the /etc/selinux/config file and set SELINUX=disabled
Save the file and reboot your CentOS system with:
Once the machine boots up, make sure that the getenforce command returns Disabled:
We are going to download Asterisk source in the /usr/src directory which is the common location to place source files.
Change to the /usr/src directory by typing:
Download the latest version of Asterisk 15 with the following wget command:
Once the download is completed, extract the downloaded file using the following command:
Before continuing with the next steps, make sure you change to the Asterisk source directory by typing:
Install Asterisk Dependencies
Download the MP3 sources which are required to build the MP3 module and use MP3 files on Asterisk:
Next install all missing dependencies with the install_prereq script:
The script will install all necessary packages and upon successful completion, it will print the following message:
The configure script will perform a number of checks to make sure all of the dependencies that are required by the build and install process are present, start the script by typing:
The next step is to select the modules you want to compile and install.
Most of the modules are already enabled. Access the Menuselect system, by typing:
Start the compilation process using the make command:
The next step is to install Asterisk and its modules by typing:
Install either the generic configuration files with reference documentation by typing:
Or install the basic PBX configuration files:
The last step is to install the Asterisk init script by typing:
Finally run ldconfig to update the shared libraries cache:
Create Asterisk User
By default Asterisk runs as a root user. For security reasons we will create a new system user and configure Asterisk to run as the newly created user.
To create a new system user named asterisk run the following command:
To configure Asterisk to run as asterisk user, open the /etc/sysconfig/asterisk file and uncomment the following two lines:
Add the asterisk user to the dialout and audio groups:
We also need to change the ownership and permissions of all asterisk files and directories so the user asterisk can access those files:
Now that we are all set up, we can start the Asterisk service with the following command:
To verify that Asterisk is running, connect to the Asterisk command line interface (CLI) by typing:
Adjust the Firewall Rules
Now that Asterisk is installed and running you need to configure your firewall to allow traffic on Asterisk specific ports.
If you don’t have firewall enabled on your system, you can skip this section.
Open your text editor of choice and create the following Firewalld service:
Save the file and apply the new firewall rules by typing:
Finally check if the new firewall rules are applied successfully with:
Feel free to adjust the firewall according to your need.
In this guide we have shown you how to install the latest Asterisk version from source on your CentOS system.