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.
-
First update your Debian box & install curl & git.1apt-get update && apt-get install -y curl git
-
Add FreeSWITCH GPG key to APT sources keyring.1curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | apt-key add -
-
Add FreeSWITCH repository to APT sources.1echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /etc/apt/sources.list.d/freeswitch.list
-
Once again update your system.1apt-get update
-
Now lets first install FreeSWITCH dependencies.1apt-get install -y --force-yes freeswitch-video-deps-most
-
Though above step takes care of most of dependencies, few still remains required to compile mod_fsv. So install them as,
1apt-get install -y libyuv-dev libvpx2-dev -
Grab source code of FreeSWITCH as follows,123git config --global pull.rebase truecd /usr/src/git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git
-
Now lets compile FreeSWITCH source for version 1.612345cd freeswitch.gitgit checkout v1.6./bootstrap.sh -j./configure -Cmake && make install
-
Now lets compile sounds1make all cd-sounds-install cd-moh-install
-
Lets create simlinks to required binaries to access them from anywhere.12ln -s /usr/local/freeswitch/bin/freeswitch /usr/bin/freeswitchln -s /usr/local/freeswitch/bin/fs_cli /usr/bin/fs_cli
Set Owner & Permissions
1 2 3 4 5 6 |
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’
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
[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
1 2 3 4 |
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.
1 |
systemctl start freeswitch.service |
Notes
- 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