Required configuration files

Various configuration files need to be set up in order to run Asterisk. We could use the make samples command to install a set of sample configuration files for Asterisk, but that would also install a lot of unnecessary files and modules that we will never use. So we are going to create our own configuration files from the scratch and set them up.

First, we need to create a directory that will hold our configuration files. Usually the Asterisk configuration files are stored in the /etc/asterisk directory. Create this directory if it doesn’t already exists:

mkdir /etc/asterisk

We need to change owner to asteriskuser and group:

chown asteriskuser:asteriskuser /etc/asterisk/

The first file we will create is indications.conf. This file defines how to detect different telephony tones for different countries. We can use the file from the Asterisk source, so simply copy the indications.conf file from the source to the /etc/asterisk directory:

cp /root/asterisk-13.13.1/configs/samples/indications.conf.sample /etc/asterisk/indications.conf

Open the file in the text editor of your choice and change the country parameter to match your country or region. The file includes the list of supported countries and lists the two-letter country codes. For example, if you are from Austria, you would have the following configuration:


The next file we need is the asterisk.conf file. This file tells Asterisk the directories where everything is, (e.g. the location of the directory containing other configuration files), and also contains many other options relevant to the core of Asterisk.

As with indications.conf, we will copy the file from the source to the /etc/asterisk/ directory:

cp /root/asterisk-13.13.1/configs/samples/asterisk.conf.sample /etc/asterisk/asterisk.conf

We need to change the user and group the Asterisk will run as. Open the file in a text editor, find the lines beginning with ;runuser and ;rungroup, uncomment them by deleting the ; character, and change their values to the Asterisk user and group you’ve created:

runuser = asteriskuser ; The user to run as.
rungroup = asteriskuser ; The group to run as.

The majority of Asterisk’s features are separated outside of the core into various modules. The modules.conf file tells Asterisk which modules to load. We need to create an empty file called modules.conf in the /etc/asterisk directory:

touch /etc/asterisk/modules.conf

Open the file in a text editor of your choice and enter the following lines:


The lines above tell Asterisk to automatically load all modules located in the /usr/lib/asterisk/modules directory.

The next file we need, the musiconhold.conf file, defines the classes for music on hold. You can define different classes and use different hold music in various situations. Let’s define the default music on hold class that will play the default music when placing callers on hold:

touch /etc/asterisk/musiconhold.conf

Write the following lines inside the file:



The mode=files line defines that the files will be played from a directory on the filesystem. The directory=moh specifies the location of the files, relative to the /var/lib/asterisk directory. So in our case, the directory that will hold the files is /var/lib/asterisk/moh.

We now have everything set to run Asterisk for the first time! To do this, simply run the following command:

asterisk -cvvvvv
If you get an error asterisk: error while loading shared libraries, run the ldconfig command to create the links and cache to the most recent shared libraries.


Asterisk should start successfully and you should be greeted with the Asterisk CLI (command-line interface). Since no modules are loaded, we can use Asterisk yet to establish calls. Press CTRL+c to stop Asterisk and exit CLI.

The -c option executed Asterisk as a foreground application. This means that the Asterisk process will run only as long you are logged in. The -v option determines the verbosity level – the number of the v characters specifies the verbosity level (from 0 to 5).
Geek University 2022