FreePBX and Asterisk Installation on CentOS 7
Prerequisites
1.Install CentOS 7 in the Client Area:
- Login to your VPS using SSH.
2.Update OS:
- Run the following command to update your system:
3.Check SELinux Status:
- Verify that SELinux is disabled:
- Ensure the result shows "Disabled."
4.Install Additional Packages:
- Install core and development tools:
yum -y groupinstall core base "Development Tools"
- Install necessary 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 libsrtp-devel libtool-ltdl libtool-ltdl-devel e2fsprogs-devel keyutils-libs-devel krb5-devel libogg libselinux-devel libsepol-devel libtiff-devel gmp audiofile-devel libogg-devel openssl-devel zlib-devel perl-DateManip sox wget net-tools psmisc speex-devel gsm-devel libtool libedit-devel xmlstarlet
5.Add PHP 5 Repositories:
- Add the EPEL and Webtatic repositories:
yum -y install php56w php56w-pdo php56w-mysql php56w-mbstring php56w-pear php56w-process php56w-xml php56w-opcache php56w-ldap php56w-intl php56w-soap
6.Set Up NodeJS:
7.Configure MySQL for Autostart:
- Enable and start MariaDB service:
systemctl enable mariadb.service
systemctl start mariadb
- Secure MySQL installation (Do not set up a root password):
mysql_secure_installation
8.Add Asterisk User:
- Add a new user named "Asterisk":
adduser asterisk -m -c "Asterisk User"
9.Set Apache to Autostart:
- Enable and start Apache service:
systemctl enable httpd.service
systemctl start httpd.service
10.Add Perl Extension:
- Install Console_Getopt:
pear install Console_Getopt
11.Install SRTP for Encrypted RTP Data:
- Download and install SRTP:
cd /usr/src
wget http://sourceforge.net/projects/srtp/files/srtp/1.4.4/srtp-1.4.4.tgz
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
12.Set Up libjansson:
- Install Jansson library:
cd /usr/src
wget -O jansson.tar.gz https://github.com/akheron/jansson/archive/v2.10.tar.gz
tar vxfz jansson.tar.gz
rm -f jansson.tar.gz
cd jansson-*
autoreconf -i
./configure --libdir=/usr/lib64
make
make install
13.Download Asterisk Packages:
- Download the necessary Asterisk packages:
cd /usr/src
wget http://sourceforge.net/projects/lame/files/lame/3.98.4/lame-3.98.4.tar.gz
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz
14.Set Up Lame for MP3 Format Coding:
- Install Lame:
cd /usr/src
tar zxvf lame-3.98.4.tar.gz
cd lame-3.98.4
./configure
make
make uninstall
make install
15.Set Up and Compile Dahdi and LibPri:
- Install 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 libpri-*
make
make install
16.Set Up and Compile Asterisk 16:
- Install and configure Asterisk:
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
contrib/scripts/get_mp3_source.sh
make menuselect
make && make install && make config && ldconfig
17.Set Ownership for Asterisk:
- Set ownership 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
18.Configure Apache:
- Update 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
19.Download FreePBX:
- Download and install FreePBX:
cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-14.0-latest.tgz
tar xfz freepbx-14.0-latest.tgz
cd freepbx
./start_asterisk start
./install -n
20.Set Up FreePBX Autostart:
- Create a service file:
nano /etc/systemd/system/freepbx.service
- Insert the following content:
[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
- Enable and start FreePBX:
systemctl enable freepbx.service
systemctl start freepbx
systemctl status -l freepbx.service
21.Open Port 80:
- Add a firewall rule to allow HTTP connections:
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
iptables-save | grep 80
You are now done with the installation. You can refer to the official FreePBX documentation for further guidance: FreePBX Documentation