
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.
Prerequisites
Install CentOS 7 in the Client Area:
Login to your VPS using SSH
Let's update our freshly installed OS:
- Let's check if SELinux is disabled as this can be a cause for unexpected troubles:
In results, you should see "Disabled"
- 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
- Let's add repositories for PHP 5:
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
- Setup nodeJS:
- Setup MySQL autostart for "cdr" record data saving from Asterisk:
systemctl enable mariadb.service
systemctl start mariadb
Setup secure settings for MySQL:
mysql_secure_installation
Attention! Do not set up any of user "root" password
- Add user "Asterisk"
adduser asterisk -m -c "Asterisk User"
- Set up Apache to autostart and star it:
systemctl enable httpd.service
systemctl start httpd.service
- Add Perl extension:
pear install Console_Getopt
- Set up "srtp" for create a possibility to Asterisk send encrypted "rtp" data:
tar zxvf srtp-*.tgz &&
sed -i 's/RTPW\=rtpw/RTPW\=.\/rtpw/' /usr/src/srtp/test/rtpw_test.sh &&
cd srtp && autoconf &&
./configure CFLAGS=-fPIC --prefix=/usr &&
make &&
make runtest &&
make uninstall &&
make install
- Setup libjansson
- Download Asterisk packets:
- 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
- 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
- Setup and compile Asterisk 16:
cd /usr/src &&
tar xvfz asterisk-16.tar.gz &&
cd asterisk-16.
Configure:
./configure --libdir=/usr/lib64 --with-pjproject-bundled --with-crypto --with-ssl=ssl --with-srtp
contrib/scripts/get_mp3_source.sh

make && make install && make config && ldconfig
- 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
- 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
- Download FreePBX:
Setup it:
cd freepbx
./start_asterisk start
./install -n
- Setup FreePBX to autostart:
Create a file:
nano /etc/systemd/system/freepbx.service
And insert this script:
[Unit]
Description=FreePBX VoIP Server
After=mariadb.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/fwconsole start -q
ExecStop=/usr/sbin/fwconsole stop -q
[Install]
WantedBy=multi-user.target
Autostart of FreePBX:
systemctl enable freepbx.service
Check if FreePBX started correctly:
systemctl status -l freepbx.service
- 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:
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: http://wiki.freepbx.org/