Asterisk Freepbx on CentOS (CentOS v7, Asterisk v14, Freepbx v14)
This covers the installation of Asterisk v13 or v14 and Freepbx v14 GUI from source on CentOS v7.
Tested on
CentOS v7 x64
Asterisk v13 and v14
Freepbx v14
Assumptions
Console text mode (multi-user.target)
Installation done as root user (#)
Prerequisites
Ensure a basic server install with initial dependencies to start with.
yum -y update && yum -y groupinstall core && yum -y groupinstall base && yum -y install epel-release && yum -y remove sendmail
yum -y install automake gcc gcc-c++ ncurses-devel openssl-devel libxml2-devel unixODBC-devel libcurl-devel libogg-devel libvorbis-devel speex-devel spandsp-devel freetds-devel net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libtool-ltdl-devel lua-devel sqlite-devel radiusclient-ng-devel portaudio-devel neon-devel libical-devel openldap-devel gmime-devel mysql-devel bluez-libs-devel jack-audio-connection-kit-devel gsm-devel libedit-devel libuuid-devel jansson-devel libsrtp-devel git subversion libxslt-devel kernel-devel audiofile-devel gtk2-devel libtiff-devel libtermcap-devel ilbc-devel python-devel bison tftp-server httpd sox tzdata mysql-connector-odbc mariadb mariadb-server fail2ban jwhois xmlstarlet ghostscript libtiff-tools patch e2fsprogs mpg123 lame gstreamer postfix mongodb-server
PHP
Install repository and replace any existing PHP packages.
yum -y install https://centos7.iuscommunity.org/ius-release.rpm yum -y install yum-plugin-replace yum replace php --replace-with php56u
Install PHP v5.6
yum -y install php56u php56u-mysqlnd php56u-process php56u-pear php56u-mbstring php56u-xml php56u-gd php56u-curl
Node.js
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash - yum -y install nodejs
ODBC
cat >> /etc/odbc.ini << EOF [MySQL-asteriskcdrdb] Description = MariaDB connection to 'asteriskcdrdb' database driver = MySQL server = localhost database = asteriskcdrdb Port = 3306 Socket = /var/lib/mysql/mysql.sock option = 3 Charset=utf8 EOF
Miscellaneous
yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm yum install ffmpeg
Set Timezone
## FIND YOUR TIMEZONE tzselect
## SET TIMEZONE EXAMPLE timedatectl set-timezone America/Vancouver
timedatectl status
Install
DAHDI
Only required if using a physical server and installing telecom hardware. At this time, versions newer than 2.10.2
(2.11.0
and 2.11.1
) do not install correctly.
cd /usr/src wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-2.10.2+2.10.2.tar.gz tar zxvf dahdi-linux-complete-2.10* cd /usr/src/dahdi-linux-complete-2.10*/ make all && make install && make config systemctl restart dahdi
If make all
fails try reboot and run apt install linux-headers*
Asterisk
To install Asterisk v14, set VERSION=14
. To switch versions, it is best to run rm -rf /usr/lib64/asterisk/modules
first.
# Select Asterisk VERSION=14 or VERSION=13
cd /usr/src wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-${VERSION}-current.tar.gz tar zxvf asterisk-${VERSION}-current.tar.gz cd /usr/src/asterisk-${VERSION}*/ make distclean
Install additional dependencies
cd /usr/src/asterisk-${VERSION}*/ ./contrib/scripts/install_prereq install
Configure
cd /usr/src/asterisk-${VERSION}*/ ./configure --libdir=/usr/lib64 --with-pjproject-bundled
To view results type nano -v config.log
.
Set compile options
cd /usr/src/asterisk-${VERSION}*/ make menuselect # Select additional compile options or leave at default and save. # To add/change compile options afterwards just run make menuselect and make && make install again.
Create Asterisk User, compile, install and set preliminary ownership.
adduser asterisk -s /sbin/nologin -c "Asterisk User"
make && make install && chown -R asterisk. /var/lib/asterisk
Freepbx
systemctl restart mariadb
cd /usr/src git clone -b release/14.0 --single-branch https://github.com/freepbx/framework.git freepbx
cd /usr/src/freepbx ./start_asterisk start ./install -n
If you get a Could not determine Asterisk version
error, modify the following line:
nano +266 installlib/installcommand.class.php
$lastline = exec("runuser" . $answers['user'] . ' -s /bin/bash -c "cd ~/ && asterisk -rx \'core show version\' | grep ^Asterisk 2>&1"', $tmpout, $ret);
Module install
fwconsole ma downloadinstall framework core voicemail sipsettings infoservices \ featurecodeadmin logfiles callrecording cdr dashboard music conferences
fwconsole chown fwconsole reload
Additional modules can be installed via GUI > Admin > Module Admin
.
Optionally, install all modules (not recommended). You will most likely need to run the following commands twice.
fwconsole ma installall fwconsole chown fwconsole reload
Set Freepbx to start on boot
nano /etc/systemd/system/freepbx.service
[Unit] Description=Freepbx After=mariadb.service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/sbin/fwconsole start ExecStop=/usr/sbin/fwconsole stop [Install] WantedBy=multi-user.target
systemctl enable freepbx
Post-install tasks
Lock down the database server.
mysql_secure_installation
Answer Y
to everything.
Change apache web server settings.
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php.ini sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf sed -i ':a;N;$!ba;s/AllowOverride None/AllowOverride All/2' /etc/httpd/conf/httpd.conf
Set required services are set to start on boot.
systemctl enable mariadb systemctl enable httpd systemctl enable postfix
Finally, reboot for all changes to take effect
reboot
Optional
Log File Rotation
If this is not done the log files will keep growing indefinitely.
nano /etc/logrotate.d/asterisk
/var/spool/mail/asterisk /var/log/asterisk/full /var/log/asterisk/dtmf /var/log/asterisk/fail2ban { weekly missingok rotate 4 #compress notifempty sharedscripts create 0640 asterisk asterisk postrotate /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null || true endscript su root root }
Firewall
systemctl enable firewalld systemctl restart firewalld
firewall-cmd --permanent --zone=public --add-service={http,https} firewall-cmd --permanent --zone=public --add-port=5060-5061/tcp firewall-cmd --permanent --zone=public --add-port=5060-5061/udp firewall-cmd --permanent --zone=public --add-port=10000-20000/udp firewall-cmd --reload
TFTP
If you plan to use hardware SIP phones you will probably want to set up TFTP.
yum -y install tftp-server nano /etc/xinetd.d/tftp
change server_args = -s /var/lib/tftpboot
to server_args = -s /tftpboot
change disable=yes
to disable=no
mkdir /tftpboot chmod 777 /tftpboot systemctl restart xinetd
firewall-cmd --permanent --zone=public --add-port=69/udp firewall-cmd --reload
Test ODBC
odbcinst -s -q
Use username & password in /etc/asterisk/res_odbc_additional.conf
to test connectivity to the DB via ODBC.
isql -v MySQL-asteriskcdrdb someusername somepassword
Test asterisk ODBC access
asterisk -vvvr CLI> odbc show
Misc. settings
Set php memory_limit = 256M
.
sed -i 's/memory_limit = .*/memory_limit = 256M/g' /etc/php.ini