FreeSWITCH

How to build and install FreeSWITCH 1.6 on Debian 8 Jessie

FreeSWITCH is an opensource telephony soft switch created in 2006. As per official wiki  page,

It is a scalable open source cross-platform telephony platform designed to route and interconnect popular communication protocols using audio, video, text or any other form of media.

Sounds good. right ?

We are using Debian for this tutorial as it is very stable & mature linux distribution and FreeSWITCH core developers’ choice-of-distribution .
You can read more about FreeSWITCH on there wiki page.

Now lets cut a crap & start an action, assuming you  already have working Debian 8 OS.

Build & Install FreeSWITCH

There are different ways to install FreeSWITCH. In this tutorial, we will see how to install it from source.

  1. First update your Debian box & install curl & git.
    apt-get update && apt-get install -y curl git
  2. Add FreeSWITCH GPG key to APT sources keyring.
    curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | apt-key add -
  3. Add FreeSWITCH repository to APT sources.
    echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /etc/apt/sources.list.d/freeswitch.list
  4. Once again update your system.
     apt-get update
  5. Now lets first install FreeSWITCH dependencies.
    apt-get install -y --force-yes freeswitch-video-deps-most
  6. Though above step takes care of most of dependencies, few still remains required to compile mod_fsv. So install them as,

     apt-get install -y libyuv-dev libvpx2-dev
  7. Grab source code of FreeSWITCH as follows,
     git config --global pull.rebase true
     cd /usr/src/
     git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git
  8. Now lets compile FreeSWITCH source for version 1.6
    cd freeswitch.git
     git checkout v1.6
     ./bootstrap.sh -j
     ./configure -C
     make && make install
  9. Now lets compile sounds
    make all cd-sounds-install cd-moh-install
  10. Lets create simlinks to required binaries to access them from anywhere.
    ln -s /usr/local/freeswitch/bin/freeswitch /usr/bin/freeswitch
    ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin/fs_cli

     

Set Owner & Permissions

cd /usr/local
groupadd freeswitch
adduser --disabled-password  --quiet --system --home /usr/local/freeswitch --gecos "FreeSWITCH Voice Platform" --ingroup freeswitch freeswitch
chown -R freeswitch:freeswitch /usr/local/freeswitch/
chmod -R ug=rwX,o= /usr/local/freeswitch/
chmod -R u=rwx,g=rx /usr/local/freeswitch/bin/

Starting FreeSWITCH service on boot automatically

To start FreeSWITCH after each boot automatically we need to set up init script. Init script is script used by init system to manipulate services. Debian 8 is now migrated to systemd init system, we will add systemd unit file.

Copy following content to ‘/lib/systemd/system/freeswitch.service’

[Unit]
Description=freeswitch
After=syslog.target network.target local-fs.target

[Service]
; service
Type=forking
PIDFile=/usr/local/freeswitch/run/freeswitch.pid
PermissionsStartOnly=true
ExecStart=/usr/local/freeswitch/bin/freeswitch -u freeswitch -g freeswitch -ncwait -nonat -rp
TimeoutSec=45s
Restart=on-failure
; exec
WorkingDirectory=/usr/local/freeswitch/bin
User=root
Group=daemon
LimitCORE=infinity
LimitNOFILE=100000
LimitNPROC=60000
;LimitSTACK=240
LimitRTPRIO=infinity
LimitRTTIME=7000000
IOSchedulingClass=realtime
IOSchedulingPriority=2
CPUSchedulingPolicy=rr
CPUSchedulingPriority=89
UMask=0007

[Install]
WantedBy=multi-user.target

Now execute following commands in your shell

chmod 750 /lib/systemd/system/freeswitch.service
ln -s /lib/systemd/system/freeswitch.service /etc/systemd/system/freeswitch.service
systemctl daemon-reload
systemctl enable freeswitch.service

Start FreeSWITCH

Now we are all set. Lets start hacking FreeSWITCH.

systemctl start freeswitch.service

 

Notes

  1. If something goes wrong & you try compilation again by ‘make clean’, sometimes you get errors regarding ‘spandsp’. To resolve them try to clean using
    ‘git clean -fdx’. For more info check this ticket – https://freeswitch.org/jira/browse/FS-6405

 

About Rohit Chormale

I am software engineer from Hyderabad, India with primary interests in distributed systems. In my leisure time, I love to read technical papers and hacking emacs.

7 thoughts on “How to build and install FreeSWITCH 1.6 on Debian 8 Jessie

  1. correction in string “systemcl daemon-reload”
    missing “t” in systemcl

    Good article, everything works fine. Thank you

  2. Thank you very much for the clear instructions. I would appreciate if you can help configuring freeswitch with tls and srtp. I have no clue how to create tls certificate.

    Best regards

  3. After installing Freeswitch, I am getting the following error, any idea
    [ERROR] fs_cli.c:1659 main() Error Connecting [Socket Connection Error]

    1. Hi AZ,
      please make sure freeswitch is running properly. You can check freeswitch status using systemd as
      `systemctl status freeswitch.service`

      If it is not running, you need to start it first using
      `systemctl start freeswitch.service`

      One important point is freeswitch takes few seconds to start and in that duration `fs_cli` can’t connect to it.

      If freeswitch is not able to start then you need to dig logs, those can be found at `/usr/local/freeswitch/log` dir

Leave a Reply

Your email address will not be published. Required fields are marked *