Crmgo Blog

Installing Asterisk 13 on CentOS 7

Installing Asterisk 13 on CentOS 7

Install the dependencies required for Asterisk to function correctly. Start and enable MySQL (MariaDB) to start on boot. By default, after installation, we can connect to our database server as root without entering a password. Therefore, we will set a password and make a few more configuration changes by running...

Installing Asterisk 13 on CentOS 7

 

Install the dependencies required for Asterisk to function correctly.

yum install -y gcc gcc-c++  lynx bison gmime-devel psmisc tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel subversion kernel-devel kernel-devel-$(uname -r) git subversion kernel-devel  crontabs cronie cronie-anacron uuid-devel libtool sqlite-devel libuuid-devel bzip2
yum install -y epel-release dmidecode gcc-c++ ncurses-devel libxml2-devel make wget openssl-devel newt-devel kernel-devel sqlite-devel libuuid-devel gtk2-devel jansson-devel binutils-devel

Start and enable MySQL (MariaDB) to start on boot.

systemctl enable mariadb.service
systemctl start mariadb.service

By default, after installation, you can connect to our database server as root without entering a password. Therefore, we will set a password and perform a few more settings by running the script:

mysql_secure_installation


Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
Thanks for using MariaDB!

 

  1. Download, extract, and compile pjproject:
    1
    wget http://www.pjsip.org/release/2.3/pjproject-2.3.tar.bz2
    1
    tar -jxvf pjproject-2.3.tar.bz2
    1
    cd pjproject-2.3
    1
    ./configure CFLAGS="-DNDEBUG -DPJ_HAS_IPV6=1" --prefix=/usr --libdir=/usr/lib64 --enable-shared --disable-video --disable-sound --disable-opencore-amr
    

     

    1
    2
    make dep
    make
    1
    2
    sudo make install
    sudo ldconfig
    1
    sudo ldconfig -p | grep pj
    

Install PearDB.

pear uninstall db
pear install db-1.7.14

 

 

Скачиваем, распаковываем и компилируем jansson
wget http://www.digip.org/jansson/releases/jansson-2.5.tar.gz
tar zvxf jansson-2.5.tar.gz
cd jansson-2.5 
./configure --prefix=/usr
make clean
make
make install 
ldconfig
cd ..

Download, extract, and compile lame.

wget http://sourceforge.net/projects/lame/files/lame/3.98.4/lame-3.98.4.tar.gz 
tar zxvf lame-3.98.4.tar.gz 
cd lame-3.98.4 
./configure
make
make install
cd ..

Download, extract, and compile DAHDI.

wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz 
tar xvfz dahdi-linux-complete-current.tar.gz
cd dahdi-linux-complete-*
make all
make install
make config
cd ..

Download, extract, and compile libpri.

wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz
tar xvfz libpri-current.tar.gz
cd libpri-*
make 
make install
cd ..

Now let's move on to the main part - download Asterisk.

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

Extract it.

tar xvfz asterisk-13-current.tar.gz
cd asterisk-13.*

For cdr_mysql to work:

yum install Mariadb-devel

Let's start installing Asterisk 13. Install the necessary modules using the make menuselect command.

./configure --libdir=/usr/lib64
contrib/scripts/get_mp3_source.sh
make menuselect

Most of the necessary modules are already enabled. You can add or remove anything. When selecting a module, a brief description of its purpose will be displayed. In the Add-ons section, to enable MP3 support, activate the 'format_mp3' module.

In the Core Sound Packages tab, select the required sound package formats.

In Music On Hold File Packages, enable all modules.

In Extras Sound Packages, enable the first 4 modules containing EN.

Continue the installation:

make
make install
make samples
make config

Create a user and grant them permissions to work with Asterisk.

useradd -m asterisk
chown asterisk.asterisk /var/run/asterisk 
chown -R asterisk.asterisk /etc/asterisk
chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
chown -R asterisk.asterisk /usr/lib64/asterisk

Restart Asterisk.

systemctl restart asterisk

 

Let's configure MySQL. Connect to MySQL.

mysql -uroot –p(пароль заданный при установке MySQL(mariadb))

After entering the password, we will be in the MySQL console. Let's create a user named asterisk with the password 'password'.

create user 'asterisk'@'localhost' identified by 'password';

Create the databases asteriskcdrdb and asterisk.

create database asterisk;
create database asteriskcdrdb;

Next, define the database owner.

GRANT ALL PRIVILEGES ON asterisk.* TO asterisk@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asterisk@localhost IDENTIFIED BY 'password';
flush privileges;

Let's proceed with security configuration. By default, CentOS 7 uses the FirewallD service instead of iptables. The FirewallD syntax looks like this:

firewall-cmd —permanent —add-port=№порта/протокол

Start and enable FirewallD to start automatically at boot.

systemctl start  firewalldsystemctl enable firewalld

Add the rules:

firewall-cmd --zone=public --add-port=5060/udp --permanent
firewall-cmd --zone=public --add-port=5061/udp --permanent
firewall-cmd --zone=public --add-port=4569/udp --permanent
firewall-cmd --zone=public --add-port=5060/tcp --permanent
firewall-cmd --zone=public --add-port=5061/tcp --permanent
firewall-cmd --zone=public --add-port=5038/tcp --permanent
firewall-cmd --zone=public --add-port=10000-20000/udp --permanent
firewall-cmd --reload

Verify that the rules have been added:

#firewall-cmd --zone=public  --list-all

public (default, active)
  interfaces: eth0
  sources:
  services: dhcpv6-client ssh
  ports: 80/tcp 5061/tcp 4569/udp 5060/tcp 10000-20000/udp 5061/udp 5060/udp 5038/tcp
  masquerade: no
  forward-ports:
  icmp-blocks: echo-reply echo-request
  rich rules:

The installation is now complete.

Installing additional codecs:

wget http://asterisk.hosting.lv/bin/codec_g729-ast130-gcc4-glibc2.2-x86_64-pentium4.so

mv codec_g729-ast130-gcc4-glibc2.2-x86_64-pentium4.so codec_g729.so

wget http://asterisk.hosting.lv/bin/codec_g723-ast130-gcc4-glibc2.2-x86_64-pentium4.so

mv codec_g723-ast130-gcc4-glibc2.2-x86_64-pentium4.so codec_g723.so

 

asterisk -vvvr

module load codec_g729.so

module load codec_g723.so

Issues encountered during installation.

Many users encounter various errors during the installation and configuration process. Therefore, we have decided to provide solutions for potential issues at the end of this article.

Problem:

[CC] format_mp3.c -> format_mp3.o
format_mp3.c:39:24: fatal error: mp3/mpg123.h: No such file or directory

Solution:

cd /usr/src/asterisk-*/
contrib/scripts/get_mp3_source.sh

 

Problem:

configure: error: *** termcap support not found

Solution:

yum install libtermcap-devel

 

Problem:

configure: *** XML documentation will not be available because the 'libxml2' development package is missing.
configure: *** Please run the 'configure' script with the '--disable-xmldoc' parameter option
configure: *** or install the 'libxml2' development package.

Solution:

yum -y install libxml2-devel

 

Problem:

Doxygen is not installed. Please install and re-run the configuration script.

Solution:

yum -y install doxygen

 

Problem:

configure: error: *** uuid support not found (this typically means the uuid development package is missing)

Solution:

yum -y install libuuid-devel

 

Problem:

Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)

Solution:

/etc/selinux/config SELINUX=disabledreboot

 

Note: This post may be AI-assisted and then human-edited. Editorial responsibility: Dmytro Lomaka, Kaltenkirchen.