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 8.0 on Debian 9 code named Stretch.
How to install FreeSWITCH on Ubuntu 18.04 LTS Bionic Beaver
How to install FreeSWITCH on Debian 8 Jessie
How to install FreeSWITCH on CentOS 7
Does FreeSWITCH seem hard ? Not really. Visit our FreeSWITCH Archive to learn more.
Installation using pre-complied package
Installation using Debian pre-complied package is straight forward. Just run below commands.
1. First fetch updated list of packages
apt-get update
2. Now install core dependencies.
apt-get install -y gnupg2 wget
3. Add address of FreeSWITCH official repository in repository-sources.
echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.8/ stretch main" > /etc/apt/sources.list.d/freeswitch.list echo "deb-src http://files.freeswitch.org/repo/deb/freeswitch-1.8/ stretch main" >> /etc/apt/sources.list.d/freeswitch.list
4. Now update package list again
apt-get update
5. Finally install FreeSWITCH
apt-get install -y freeswitch-meta-all
6. Now check status of FreeSWITCH service
systemctl status freeswitch
7. Sometimes you may get status as ‘failed’ like below.
● freeswitch.service - freeswitch Loaded: loaded (/lib/systemd/system/freeswitch.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2019-05-27 10:51:21 UTC; 2min 6s ago
This could be because of time FreeSWITCH takes to start. In this case try to start service again using below command
systemctl start freeswitch.service
Check again status. Final status should be ‘active’ 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
8. Now you can connect FreeSWITCH using fs_cli as below
fs_cli -rRS
Installation from source
1. Fetch updated list of packages
apt-get update
2. Install core dependencies
apt-get install -y gnupg2 wget
3. Add FreeSWITCH official key to list of trusted keys
wget -O - https://files.freeswitch.org/repo/deb/freeswitch-1.8/fsstretch-archive-keyring.asc | apt-key add -
4. Add address of FreeSWITCH official repository in repository-sources.
echo “deb http://files.freeswitch.org/repo/deb/freeswitch-1.8/ stretch main” > /etc/apt/sources.list.d/freeswitch.list
echo “deb-src http://files.freeswitch.org/repo/deb/freeswitch-1.8/ stretch main” >> /etc/apt/sources.list.d/freeswitch.list
5. Now re-index packages
apt-get update
6. Installed dependencies
apt-get build-dep freeswitch
7. Now grab source. Use the -b flag to get a specific branch
cd /usr/src
git clone https://freeswitch.org/stash/scm/fs/freeswitch.git -bv1.8 freeswitch
cd freeswitch
8. As we are in a branch that will go through many rebases, to avoid conflits better config rebase settings
git config pull.rebase true
9. Start bootstrapping
./bootstrap.sh -j
10. 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.
11. Now run standard installation process
./configure -C
make
make install
12. Compile sounds
make all cd-sounds-install cd-moh-install
13. 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
14. Add new group and user with less privileges to run FreeSWITCH service.
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/
15. Now lets add systemd unit file. Systemd is default init system for Debian 9. 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=syslog.socket network.target local-fs.target After=syslog.socket network.target network-online.target local-fs.target [Service] Type=forking Environment="DAEMON_OPTS=-nonat" EnvironmentFile=-/etc/default/freeswitch ExecStartPre=/bin/chown -R freeswitch:freeswitch /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
16. Now start service and enable it to start on boot.
chmod ugo+x freeswitch.service
systemctl start freeswitch.service
systemctl enable freeswitch.service
17. 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
18. 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. Feel free to add comment below if you encounter any problem.