Telephony

How to install Freeswitch on CentOS 7

tele-operator

FreeSWITCH is a free and opensource telecom software stack. It supports all major operating systems like Linux, Windows, macOS and freeBSD. In this article, we will see how to install Freeswitch 1.8 from source on CentOS 7. Though Debian is FreeSWITCH core developers’ choice of distribution, CentOS is immensely popular because of its enterprise quality. If you want to install on other distributions please follow below links

How to install FreeSWITCH on Ubuntu 18.04 LTS Bionic Beaver

How to install FreeSWITCH on Debian 9 Stretch

How to install FreeSWITCH on Debian 8 Jessie

Does FreeSWITCH seems hard ? Not really. Visit our FreeSWITCH Archive to learn more.

Installation from Source

1. Fetch updated list of packages

yum update -y 

2. Install some basic packages for compilation and enable EPEL repository

yum groupinstall -y 'Development Tools'
yum install -y epel-release
yum update -y

3. Install FreeSWITCH dependencies

yum install -y git autoconf automake libtool gcc-c++ libuuid-devel zlib-devel libjpeg-devel ncurses-devel openssl-devel sqlite-devel curl-devel pcre-devel speex-devel ldns ldns-devel libedit-devel gtk+-devel gtk2-devel yasm-devel lua-devel opus-devel e2fsprogs-devel libyuv-devel lua-devel libsndfile-devel libshout-devel lame-devel libvpx-devel opusfile libbroadvoice-dev

4. Now grab FreeSWITCH source. Use the -b flag to get a specific branch

cd /usr/src
git clone -b v1.6 https://freeswitch.org/stash/scm/fs/freeswitch.git
cd /usr/src/freeswitch

5. As we are in a branch that will go through many rebases, to avoid conflicts better config rebase settings

git config pull.rebase true
./bootstrap.sh -j

6. By default, only few modules are enabled. You can enable/disable these modules at this stage. Edit ‘modules.conf’ and change as per requirements. Remember enabling new modules may require additional dependencies.

7. Now run standard installation process

./configure -C

There is known issue here related with libvpx, we have to fix. Open /usr/src/freeswitch/src/mod/codecs/mod_opus/Makefile in your favorite editor. And comment out lines 889 and 890.

# install:error
# all:error

Save file and run below commands to start compilation.

make
make install

8. Install sounds

make cd-sounds-install
make cd-moh-install

9. Create simlinks to use services easily

ln -s /usr/local/freeswitch/bin/freeswitch /usr/bin/
ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin

10. Add new group and user with less privileges to run FreeSWITCH service

cd /usr/local
useradd --system --home-dir /usr/local/freeswitch -G daemon freeswitch
passwd -l freeswitch

chown -R freeswitch:daemon /usr/local/freeswitch/
chmod -R ug=rwX,o= /usr/local/freeswitch/
chmod -R u=rwx,g=rx /usr/local/freeswitch/bin/

11. Create systemd unit file. Systemd is default init system for CentOS 7. Open new file ‘/etc/systemd/system/freeswitch.service’ using your favorite editor and copy below content in it.

[Unit]
Description=freeswitch
Wants=network-online.target
Requires=network.target local-fs.target
After=network.target network-online.target local-fs.target

[Service]
Type=forking
Environment="DAEMON_OPTS=-nonat"
EnvironmentFile=-/etc/default/freeswitch
ExecStartPre=/bin/chown -R freeswitch:daemon /usr/local/freeswitch
ExecStart=/usr/bin/freeswitch -u freeswitch -g freeswitch -ncwait $DAEMON_OPTS
TimeoutSec=45s
Restart=always

User=root
Group=daemon
LimitCORE=infinity
LimitNOFILE=100000
LimitNPROC=60000
LimitSTACK=250000
LimitRTPRIO=infinity
LimitRTTIME=infinity
IOSchedulingClass=realtime
IOSchedulingPriority=2
CPUSchedulingPolicy=rr
CPUSchedulingPriority=89
UMask=0007
NoNewPrivileges=false

[Install]
WantedBy=multi-user.target

12. Now start service and enable it to start on boot.

chmod ugo+x /etc/systemd/system/freeswitch.service
systemctl start freeswitch.service
systemctl enable freeswitch.service

13. Now check status of FreeSWITCH service
systemctl status freeswitch.service
Status should be ‘active‘ something like below

‚óŹ freeswitch.service – freeswitch
Loaded: loaded (/lib/systemd/system/freeswitch.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2019-05-27 10:55:15 UTC; 7min ago

14. Now you can connect to FreeSWITCH using client as below
fs_cli -r

Notes

During compilation if you stuck with errors like unknown dependencies (particularly spansdsp), run below command before starting compilation again.

git clean -fdx

Hope you like this article. Let us know feedback in comments.

Leave a Reply