Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

[CentOS] FreePBX 14 and Asterisk 16 installation on CentOS 7

LaurabLaurab Moderator
edited May 2020 in Web Applications

FreePBX is a web-based open source GUI (graphical user interface) that controls and manages Asterisk (PBX), an open source communication server. FreePBX is licensed under the GNU General Public License (GPL), an open source license.  We will install FreePBX and Asterisk on freshly installed CentOS 7.


Install CentOS 7 in the Client Area:
Login to your VPS using SSH

Let's update our freshly installed OS:
yum update
1. Let's check if SELinux is disabled as this can be a cause for unexpected troubles:
In results, you should see "Disabled"

2. Install additional packets that we need to set up FreePBX and Asterisk:
yum -y groupinstall core base "Development Tools"
Install additional dependencies:
yum -y install lynx tftp-server unixODBC unixODBC-devel mysql-connector-odbc mariadb-server mariadb httpd ncurses-devel sendmail sendmail-cf sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel subversion kernel-devel kernel-headers git crontabs cronie cronie-anacron wget vim uuid-devel sqlite sqlite-devel net-tools gnutls-devel python-devel texinfo libuuid-devel libxml2-devel libsrtp-devel libtool-ltdl libtool-ltdl-devel e2fsprogs-devel keyutils-libs-devel krb5-devel libogg libselinux-devel libsepol-devel libxml2-devel libtiff-devel gmp audiofile-devel libogg-devel openssl-devel zlib-devel perl-DateManip sox git wget net-tools psmisc speex-devel gsm-devel libtool libedit-devel libtool-ltdl libtool-ltdl-devel xmlstarlet
3. Let's add repositories for PHP 5:
rpm -Uvh
rpm -Uvh
Install PHP 5.6 for FreePBX
yum -y install php56w php56w-pdo php56w-mysql php56w-mbstring php56w-pear php56w-process php56w-xml php56w-opcache php56w-ldap php56w-intl php56w-soap
4. Setup nodeJS:
curl -sL | bash --
yum install -y nodejs
5. Setup MySQL autostart for "cdr" record data saving from Asterisk:
systemctl enable mariadb.service
systemctl start mariadb
Setup secure settings for MySQL:
Attention! Do not set up any of user "root" password

6. Add user "Asterisk"
adduser asterisk -m -c "Asterisk User"
7. Set up Apache to autostart and star it:
systemctl enable httpd.service
systemctl start httpd.service
8. Add Perl extension:
pear install Console_Getopt
9. Set up "srtp" for create a possibility to Asterisk send encrypted "rtp" data:
cd /usr/src && wget
tar zxvf srtp-*.tgz &&
sed -i 's/RTPW\=rtpw/RTPW\=\.\/rtpw/' /usr/src/srtp/test/ &&
cd srtp && autoconf &&
./configure CFLAGS=-fPIC --prefix=/usr &&
make &&
make runtest &&
make uninstall &&
make install
10. Setup libjansson
cd /usr/src
wget -O jansson.tar.gz
tar vxfz jansson.tar.gz
rm -f jansson.tar.gz
cd jansson-*
autoreconf -i
./configure --libdir=/usr/lib64
make install
11. Download Asterisk packets:
cd /usr/src &&
wget &&
wget &&
wget &&
12. Setup Lame for MP3 format coding:
cd /usr/src &&
tar zxvf lame-3.98.4.tar.gz &&
cd lame-3.98.4 &&
./configure &&
make &&
make uninstall &&
make install
13. Setup and compile Dahdi and LibPri:
cd /usr/src &&
tar xvfz dahdi-linux-complete-current.tar.gz &&
cd dahdi-linux-complete-* &&
make all &&
make install &&
make config
cd /usr/src &&
tar xvfz libpri-*.tar.gz &&
cd /usr/src/libpri-* &&
make &&
make install
14. Setup and compile Asterisk 16:
cd /usr/src &&
tar xvfz asterisk-16*.tar.gz &&
cd asterisk-16.*
./configure --libdir=/usr/lib64 --with-pjproject-bundled --with-crypto --with-ssl=ssl --with-srtp
make menuselect

make && make install && make config && ldconfig
15. Change owner privileges:
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
16. Change apache settings:
sed -i 's/^upload_max_filesize = .*/upload_max_filesize = 120M/' /etc/php.ini
sed -i 's/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf &&
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf
systemctl restart httpd.service && systemctl enable httpd

FreePBX installation and setup

17. Download FreePBX:
cd /usr/src
tar xfz freepbx-14.0-latest.tgz
Setup it:
cd freepbx
./start_asterisk start
./install -n
18. Setup FreePBX to autostart:
Create a file:
nano /etc/systemd/system/freepbx.service
And insert this script:
Description=FreePBX VoIP Server
ExecStart=/usr/sbin/fwconsole start -q
ExecStop=/usr/sbin/fwconsole stop -q
Autostart of FreePBX:
systemctl enable freepbx.service
systemctl start freepbx
Check if FreePBX started correctly:
systemctl status -l freepbx.service
19. By default the port 80 for http connection is filtered on our CentOS template as you can only access this port from the actual localhost and not from any other public host. To open a port 80 on we need to add an iptables rule. For this template uses firewall-cmd. First, add your port 80 rule with a following command:
firewall-cmd --zone=public --add-port=80/tcp --permanent
Once you add the above firewall rule reload firewall service:
firewall-cmd --reload
And check whether the port was added to ipatables rules:
iptables-save | grep 80
-A IN_public_allow -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW -j ACCEPT
And you are DONE!  FreePBX documentation:

Sign In or Register to comment.


Learn how to install a web and database server, email, FTP client or other applications. Discover and share information on server security or optimization recommendations.
Feel free to join our constantly expanding community, participate in discussions, strengthen your knowledge on Linux and Windows server management!
© 2013 - 2024 Time4VPS. All rights reserved.

Get In Touch