How to install and configure Asterisk in CentOS
To Install and Configure Asterisk 13 (PBX) in CentOS
Asterisk (PBX) is a free server for creating communication applications. It is used to connect the employees from home to the office PBX through broadband connections. Installation and configuration of Asterisk is explained in this manual.
To install Asterisk
Utilise the following command to install the dependencies.
[root@linuxhelp1 ~]# yum install gcc gcc-c++ php-xml php php-mysql php-pear php-mbstring mariadb-devel mariadb-server mariadb sqlite-devel 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 uuid-devel libtool libuuid-devel subversion kernel-devel kernel-devel-$(uname -r) git subversion kernel-devel php-process crontabs cronie cronie-anacron wget vim -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
* extras: mirror.nbrc.ac.in
* updates: mirror.nbrc.ac.in
Resolving Dependencies
--> Running transaction check
---> Package audiofile-devel.x86_64 1:0.3.6-4.el7 will be installed
--> Processing Dependency: audiofile = 1:0.3.6-4.el7 for package: 1:audiofile-devel-0.3.6-4.el7.x86_64
--> Processing Dependency: libaudiofile.so.1()(64bit) for package: 1:audiofile-devel-0.3.6-4.el7.x86_64
---> Package bind.x86_64 32:9.9.4-29.el7_2.3 will be installed
---> Package bison.x86_64 0:2.7-4.el7 will be installed
---> Package gcc.x86_64 0:4.8.5-4.el7 will be installed
.
.
.
perl-TermReadKey.x86_64 0:2.30-20.el7 pixman-devel.x86_64 0:0.32.6-3.el7
procmail.x86_64 0:3.22-35.el7 slang-devel.x86_64 0:2.2.4-11.el7
subversion-libs.x86_64 0:1.7.14-10.el7 uuid.x86_64 0:1.6.2-26.el7
xorg-x11-proto-devel.noarch 0:7.7-12.el7 xz-devel.x86_64 0:5.1.2-12alpha.el7
Complete!
To Setup MariaDB
After installation, enable mariadb services to setup its root password.
[root@linuxhelp1 ~]# systemctl enable mariadb Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service. [root@linuxhelp1 ~]# systemctl start mariadb
[root@linuxhelp1 ~]# systemctl status mariadb mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service enabled vendor preset: disabled) Active: active (running) since Fri 2016-07-15 15:49:04 IST 15s ago Process: 942 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS) Process: 862 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS) Main PID: 941 (mysqld_safe) CGroup: /system.slice/mariadb.service ?? 941 /bin/sh /usr/bin/mysqld_safe --basedir=/usr ??1101 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/... Jul 15 15:48:58 linuxhelp1 mariadb-prepare-db-dir[862]: The latest information about MariaDB is available at http://mariadb.org/. Jul 15 15:48:58 linuxhelp1 mariadb-prepare-db-dir[862]: You can find additional information about the MySQL part at: Jul 15 15:48:58 linuxhelp1 mariadb-prepare-db-dir[862]: http://dev.mysql.com Jul 15 15:48:58 linuxhelp1 mariadb-prepare-db-dir[862]: Support MariaDB development by buying support/new features from MariaDB Jul 15 15:48:58 linuxhelp1 mariadb-prepare-db-dir[862]: Corporation Ab. You can contact us about this at sales@mariadb.com. Jul 15 15:48:58 linuxhelp1 mariadb-prepare-db-dir[862]: Alternatively consider joining our community based development effort: Jul 15 15:48:58 linuxhelp1 mariadb-prepare-db-dir[862]: http://mariadb.com/kb/en/contributing-to-the-mariadb-project/ Jul 15 15:48:59 linuxhelp1 mysqld_safe[941]: 160715 15:48:59 mysqld_safe Logging to ' /var/log/mariadb/mariadb.log' . Jul 15 15:48:59 linuxhelp1 mysqld_safe[941]: 160715 15:48:59 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql Jul 15 15:49:04 linuxhelp1 systemd[1]: Started MariaDB database server
Run the following command to setup the root password.
[root@linuxhelp1 ~]# mysql_secure_installation /usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we' ll need the current password for the root user. If you' ve just installed MariaDB, and you haven' t set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from ' localhost' . This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named ' test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you' ve completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
Utilise the following command to install libjansson.
[root@linuxhelp1 ~]# wget http://www.digip.org/jansson/releases/jansson-2.7.tar.gz
--2016-07-15 15:51:10-- http://www.digip.org/jansson/releases/jansson-2.7.tar.gz
Resolving www.digip.org (www.digip.org)... 91.232.156.81, 91.232.156.82
Connecting to www.digip.org (www.digip.org)|91.232.156.81|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 445179 (435K) [application/x-gzip]
Saving to: ‘ jansson-2.7.tar.gz’
100%[=============================================================================================> ] 4,45,179 125KB/s in 3.5s
2016-07-15 15:51:16 (125 KB/s) - ‘ jansson-2.7.tar.gz’ saved [445179/445179]
Extract the downloaded package by using the following command.
[root@linuxhelp1 ~]# tar -zxvf jansson-2.7.tar.gz
jansson-2.7/
jansson-2.7/Makefile.am
jansson-2.7/aclocal.m4
jansson-2.7/cmake/
jansson-2.7/cmake/JanssonConfig.cmake.in
.
.
.
jansson-2.7/test/scripts/valgrind.sh
jansson-2.7/test/scripts/run-tests.sh
jansson-2.7/test/run-suites
jansson-2.7/jansson.pc.in
Go to the extracted directory and run the following command to configure it.
[root@linuxhelp1 ~]# cd jansson-2.7/ [root@linuxhelp1 jansson-2.7]# ./configure --prefix=/usr checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes . . . config.status: creating test/suites/api/Makefile config.status: creating jansson_private_config.h config.status: executing depfiles commands config.status: executing libtool commands
Run the following commands to execute make script.
[root@linuxhelp1 jansson-2.7]# make clean Making clean in doc make[1]: Entering directory `/root/jansson-2.7/doc' rm -rf .libs _libs rm -rf _build rm -f ext/refcounting.pyc rm -f *.lo make[1]: Leaving directory `/root/jansson-2.7/doc' Making clean in src . . . make[1]: Entering directory `/root/jansson-2.7' rm -rf .libs _libs rm -f *.lo make[1]: Leaving directory `/root/jansson-2.7' [root@linuxhelp1 jansson-2.7]# make make all-recursive make[1]: Entering directory `/root/jansson-2.7' Making all in doc make[2]: Entering directory `/root/jansson-2.7/doc' make[2]: Nothing to be done for `all' . make[2]: Leaving directory `/root/jansson-2.7/doc' Making all in src make[2]: Entering directory `/root/jansson-2.7/src' . . . make[1]: Leaving directory `/root/jansson-2.7' [root@linuxhelp1 jansson-2.7]# make install Making install in doc make[1]: Entering directory `/root/jansson-2.7/doc' make[2]: Entering directory `/root/jansson-2.7/doc' make[2]: Nothing to be done for `install-exec-am' . make[2]: Nothing to be done for `install-data-am' . make[2]: Leaving directory `/root/jansson-2.7/doc' make[1]: Leaving directory `/root/jansson-2.7/doc' . . . make[1]: Leaving directory `/root/jansson-2.7'
Installing Asterisk 13.10.0
Download the latest package from its official website,
http://downloads.asterisk.org/pub/telephony/asterisk/ .
Use wget command to download the package as follows.
[root@linuxhelp1 jansson-2.7]# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13.10.0-rc3.tar.gz
--2016-07-15 15:54:09-- http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13.10.0-rc3.tar.gz
Resolving downloads.asterisk.org (downloads.asterisk.org)... 76.164.171.238, 2001:470:e0d4::ee
Connecting to downloads.asterisk.org (downloads.asterisk.org)|76.164.171.238|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 32606288 (31M) [application/x-gzip]
Saving to: ‘ asterisk-13.10.0-rc3.tar.gz’
100%[=============================================================================================> ] 3,26,06,288 155KB/s in 5m 24s
2016-07-15 15:59:37 (98.3 KB/s) - ‘ asterisk-13.10.0-rc3.tar.gz’ saved [32606288/32606288]
Extract the downloaded package
[root@linuxhelp1 jansson-2.7]# tar -zxvf asterisk-13.10.0-rc3.tar.gz
asterisk-13.10.0-rc3/
asterisk-13.10.0-rc3/Makefile.moddir_rules
asterisk-13.10.0-rc3/missing
asterisk-13.10.0-rc3/CREDITS
asterisk-13.10.0-rc3/makeopts.in
.
.
.
asterisk-13.10.0-rc3/doc/smsq.8
asterisk-13.10.0-rc3/doc/asterisk.sgml
asterisk-13.10.0-rc3/doc/asterisk-ng-doxygen.in
asterisk-13.10.0-rc3/doc/appdocsxml.dtd
Open the Asterisk directory and execute the configure script
[root@linuxhelp1 jansson-2.7]# cd asterisk-13.10.0-rc3/ [root@linuxhelp1 asterisk-13.10.0-rc3]# ./configure --libdir=/usrllib64 checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out . . . .$$$$$$$$$$$$$$$=.. .$7$7.. .7$$7:. .$$:. ,$7.7 .$7. 7$$$$ .$$77 ..$$. $$$$$ .$$$7 ..7$ .?. $$$$$ .?. 7$$$. $.$. .$$$7. $$$$7 .7$$$. .$$$. .777. .$$$$$$77$$$77$$$$$7. $$$, $$$~ .7$$$$$$$$$$$$$7. .$$$. .$$7 .7$$$$$$$7: ?$$$. $$$ ?7$$$$$$$$$$I .$$$7 $$$ .7$$$$$$$$$$$$$$$$ :$$$. $$$ $$$$$$7$$$$$$$$$$$$ .$$$. $$$ $$$ 7$$$7 .$$$ .$$$. $$$$ $$$$7 .$$$. 7$$$7 7$$$$ 7$$$ $$$$$ $$$ $$$$7. $$ (TM) $$$$$$$. .7$$$$$$ $$ $$$$$$$$$$$$7$$$$$$$$$.$$$$$$ $$$$$$$$$$$$$$$$. configure: Package configured for: configure: OS type : linux-gnu configure: Host CPU : x86_64 configure: build-cpu:vendor:os: x86_64 : unknown : linux-gnu : configure: host-cpu:vendor:os: x86_64 : unknown : linux-gnu :
Asterisk Modules Setup
Run the following command and select appropriate options to add/delete the modules.
[root@linuxhelp1 asterisk-13.10.0-rc3]# make menuselect
CC=" cc" CXX=" g++" LD=" " AR=" " RANLIB=" " CFLAGS=" " LDFLAGS=" " make -C menuselect CONFIGURE_SILENT=" --silent" cmenuselect
make[1]: Entering directory `/root/jansson-2.7/asterisk-13.10.0-rc3/menuselect'
gcc -g -D_GNU_SOURCE -Wall -I/usr/include/libxml2 -c -o menuselect.o menuselect.c
gcc -g -D_GNU_SOURCE -Wall -c -o strcompat.o strcompat.c
gcc -g -D_GNU_SOURCE -Wall -c -o menuselect_curses.o menuselect_curses.c
.
.
.
To Load mp3 Libraries
Run the following command to download the mp3 decoder library into the source.
[root@linuxhelp1 asterisk-13.10.0-rc3]# contrib/scripts/get_mp3_source.sh
A addons/mp3
A addons/mp3/MPGLIB_README
A addons/mp3/common.c
A addons/mp3/huffman.h
A addons/mp3/tabinit.c
A addons/mp3/Makefile
A addons/mp3/README
A addons/mp3/decode_i386.c
A addons/mp3/dct64_i386.c
A addons/mp3/MPGLIB_TODO
A addons/mp3/mpg123.h
A addons/mp3/layer3.c
A addons/mp3/mpglib.h
A addons/mp3/decode_ntom.c
A addons/mp3/interface.c
Exported revision 202.
To install modules
Install the selected modules using the make script.
[root@linuxhelp1 asterisk-13.10.0-rc3]# make
Generating embedded module rules ...
[CC] astcanary.c -> astcanary.o
[LD] astcanary.o -> astcanary
[CC] astdb2sqlite3.c -> astdb2sqlite3.o
[CC] hash/hash.c -> hash/hash.o
[CC] hash/hash_bigkey.c -> hash/hash_bigkey.o
.
.
.
[CC] res_config_mysql.c -> res_config_mysql.o
[LD] res_config_mysql.o -> res_config_mysql.so
Building Documentation For: third-party channels pbx apps codecs formats cdr cel bridges funcs tests main res addons
+--------- Asterisk Build Complete ---------+
+ Asterisk has successfully been built, and +
+ can be installed by running: +
+ +
+ make install +
+-------------------------------------------+
Run the command as shown in the above output to install asterisk.
[root@linuxhelp1 asterisk-13.10.0-rc3]# make install
Installing modules from channels...
Installing modules from pbx...
Installing modules from apps...
Installing modules from codecs...
Installing modules from formats...
.
.
.
make[1]: Leaving directory `/root/jansson-2.7/asterisk-13.10.0-rc3/sounds'
find rest-api -name " *.json" | while read x do
/usr/bin/install -c -m 644 $x " /var/lib/asterisk/rest-api"
done
+---- Asterisk Installation Complete -------+
+ +
+ YOU MUST READ THE SECURITY DOCUMENT +
+ +
+ Asterisk has successfully been installed. +
+ If you would like to install the sample +
+ configuration files (overwriting any +
+ existing config files), run: +
+ +
+ For generic reference documentation: +
+ make samples +
+ +
+ For a sample basic PBX: +
+ make basic-pbx +
+ +
+ +
+----------------- or ---------------------+
+ +
+ You can go ahead and install the asterisk +
+ program documentation now or later run: +
+ +
+ make progdocs +
+ +
+ **Note** This requires that you have +
+ doxygen installed on your local system +
+-------------------------------------------+
Now install the sample configuration files.
[root@linuxhelp1 asterisk-13.10.0-rc3]# make samples
Installing adsi config files...
/usr/bin/install -c -d " /etc/asterisk"
Installing configs/samples/asterisk.adsi
Installing configs/samples/telcordia-1.adsi
Installing other config files...
Installing file configs/samples/acl.conf.sample
Installing file configs/samples/adsi.conf.sample
Installing file configs/samples/agents.conf.sample
Installing file configs/samples/alarmreceiver.conf.sample
Installing file configs/samples/alsa.conf.sample
Installing file configs/samples/amd.conf.sample
.
.
.
Installing file phoneprov/000000000000-directory.xml
Installing file phoneprov/000000000000-phone.cfg
Installing file phoneprov/polycom_line.xml
Installing file phoneprov/polycom.xml
Installing file phoneprov/snom-mac.xml
Run the following make config command.
[root@linuxhelp1 asterisk-13.10.0-rc3]# make config
if [ -f /etc/redhat-release -o -f /etc/fedora-release ] then
./build_tools/install_subst contrib/init.d/rc.redhat.asterisk " /etc/rc.d/init.d/asterisk"
if [ ! -f " /etc/sysconfig/asterisk" ] then
/usr/bin/install -c -m 644 contrib/init.d/etc_default_asterisk " /etc/sysconfig/asterisk"
fi
.
.
.
fi
elif [ -f /etc/slackware-version ] then
echo " Slackware is not currently supported, although an init script does exist for it."
else
echo " We could not install init scripts for your distribution."
fi
To Setup Asterisk User
Create a separate user by running the following command.
[root@linuxhelp1 asterisk-13.10.0-rc3]# useradd -m asterisk [root@linuxhelp1 asterisk-13.10.0-rc3]# chown -R asterisk.asterisk /var/run/asterisk/ [root@linuxhelp1 asterisk-13.10.0-rc3]# chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
Start and enable the firewalld services.
[root@linuxhelp1 asterisk-13.10.0-rc3]# systemctl start firewalld [root@linuxhelp1 asterisk-13.10.0-rc3]# systemctl enable firewalld
Allow access to the following ports that is used by Asterisk PBX.
[root@linuxhelp1 asterisk-13.10.0-rc3]# firewall-cmd --zone=public --add-port=5060/udp --permanent success [root@linuxhelp1 asterisk-13.10.0-rc3]# firewall-cmd --zone=public --add-port=5060/tcp --permanent success [root@linuxhelp1 asterisk-13.10.0-rc3]# firewall-cmd --zone=public --add-port=5061/tcp --permanent success [root@linuxhelp1 asterisk-13.10.0-rc3]# firewall-cmd --zone=public --add-port=5061/udp --permanent success [root@linuxhelp1 asterisk-13.10.0-rc3]# firewall-cmd --zone=public --add-port=4569/udp --permanent success [root@linuxhelp1 asterisk-13.10.0-rc3]# firewall-cmd --zone=public --add-port=5038/tcp --permanent success [root@linuxhelp1 asterisk-13.10.0-rc3]# firewall-cmd --zone=public --add-port=10000-20000/udp --permanent success [root@linuxhelp1 asterisk-13.10.0-rc3]# firewall-cmd --reload success
To Setup Asterisk Database
Connect to the MySQL MariaDB by using the following command.
[root@linuxhelp1 asterisk-13.10.0-rc3]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with or g. Your MariaDB connection id is 11 Server version: 5.5.47-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type ' help ' or ' h' for help. Type ' c' to clear the current input statement. MariaDB [(none)]> create user asterisk@localhost identified by ' linuxc' Query OK, 0 rows affected (0.10 sec) MariaDB [(none)]> create database asterisk Query OK, 1 row affected (0.02 sec) MariaDB [(none)]> create database cdrdb Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all privileges on asterisk.* to asterisk@localhost identified by ' linuxc' Query OK, 0 rows affected (0.03 sec) MariaDB [(none)]> grant all privileges on cdrdb.* to asterisk@localhost identified by ' linuxc' Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit Bye
Restart and enable Asterisk
[root@linuxhelp1 asterisk-13.10.0-rc3]# systemctl restart asterisk [root@linuxhelp1 asterisk-13.10.0-rc3]# systemctl enable asterisk.service asterisk.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig asterisk on
Check the status of Asterisk.
[root@linuxhelp1 asterisk-13.10.0-rc3]# systemctl status asterisk asterisk.service - LSB: Asterisk PBX Loaded: loaded (/etc/rc.d/init.d/asterisk) Active: active (running) since Sat 2016-07-16 09:59:00 IST 5s ago Docs: man:systemd-sysv-generator(8) Process: 24740 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS) Main PID: 25245 CGroup: /system.slice/asterisk.service ??25243 /bin/sh /usr/sbin/safe_asterisk ??25507 /bin/sh /usr/sbin/safe_asterisk Jul 16 09:58:59 linuxhelp1 systemd[1]: Starting LSB: Asterisk PBX... Jul 16 09:59:00 linuxhelp1 asterisk[24740]: Starting asterisk: Jul 16 09:59:00 linuxhelp1 systemd[1]: PID file /var/run/asterisk/asterisk.pid not readable (yet?) after start. Jul 16 09:59:00 linuxhelp1 systemd[1]: asterisk.service: Supervising process 25245 which is not our child. We' ll mo...exits. Jul 16 09:59:00 linuxhelp1 systemd[1]: Started LSB: Asterisk PBX. Hint: Some lines were ellipsized, use -l to show in full.
To Launch Asterisk
Utilise the following command to launch Asterisk.
[root@linuxhelp1 asterisk-13.10.0-rc3]# asterisk -vvvc
Asterisk 13.10.0-rc3, Copyright (C) 1999 - 2014, Digium, Inc. and others.
Created by Mark Spencer < markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY type ' core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses you are welcome to redistribute it under
certain conditions. Type ' core show license' for details.
.
.
.
== app_queue.so => (True Call Queueing)
== Parsing ' /etc/asterisk/cli_permissions.conf' : Found
== Parsing ' /etc/asterisk/cli.conf' : Found
Asterisk Ready.
*CLI>
*CLI>
Comments ( 0 )
No comments available