Installing Freeswitch on ubuntu.

Chetan Pandey
5 min readAug 22, 2021

In this blog/tutorial we will learn how to install Freeswitch on an Ubuntu virtual machine. The steps for Freeswitch installation will be almost the same for the supported OS. So let's get your hand dirty.

Note: You can use any VM, a dedicated machine, or any cloud service(AWS, GCP, Azure). I will be using ubuntu 21.04 running on a Vmware workstation with base OS Windows 10.

You can use the precompiled package but compiling from source provides full control over the Freeswitch.

Freeswitch source code is available at Github signalwire/freeswitch

Source code overview

Freeswitch is written in C/C++ and uses cmake for compilation. We will go step by step and compile Freeswitch on our machine

  • Download source code from Github.
# make sure you are logged in as a root user.cd /usr/local/src# clone source code and checkout branch v1.10  
git clone -b v1.10 https://github.com/signalwire/freeswitch.git
  • Freeswitch source code structure
freeswitch/
├── build # contains build files
├── clients # contains client scripts
├── cmake_modules # contains some cmake module
├── conf # contains default configuration and other conf files
├── debian # contains debian related files
├── docker # contains docker file
├── docs # documentation folder
├── dtd # contains dtd files
├── fonts # contains fonts file
├── fscomm # contains some tools
├── htdocs # contains html docs
├── images # contains images
├── libs # contains external libraries
├── scripts # contains scripts
├── src # contains main source code of freeswitch
├── support-d # contains file related to support
├── tests # contains test cases
├── w32 # contains file related to windows build
├── web # empty now
└── yum # contains files for yum pkg manager

Note: Terminal might seem to go crazy with logging so have patience don't close the terminal or try to terminate it.

Let's install Freeswitch:

  • Install FreeSWITCH dependencies
apt-get update && apt-get install -yq gnupg2 wget lsb-releasewget -O - https://files.freeswitch.org/repo/deb/debian-release/fsstretch-archive-keyring.asc | apt-key add -

echo "deb http://files.freeswitch.org/repo/deb/debian-release/ `lsb_release -sc` main" > /etc/apt/sources.list.d/freeswitch.list
echo "deb-src http://files.freeswitch.org/repo/deb/debian-release/ `lsb_release -sc` main" >> /etc/apt/sources.list.d/freeswitch.listapt-get updateapt-get build-dep freeswitch
  • Now sofia-sip and spandsp are not part of the Freeswitch source code so we have to compile them as well.
cd /usr/local/src # our source code directory git clone -b master https://github.com/freeswitch/spandsp.gitgit clone -b master https://github.com/freeswitch/sofia-sip.git# copy them to the freeswitch directories
cp /usr/local/src/spandsp /usr/local/src/freeswitch/libs/spandsp -r
cp /usr/local/src/sofia-sip /usr/local/src/freeswitch/libs/sofia-sip -r# compile modsofia and spandsp
cd /usr/local/src/freeswitch/libs/spandsp
./bootstrap.sh &&./configure && make && make install
cd /usr/local/src/freeswitch/libs/sofia-sip
./bootstrap.sh && ./configure && make && make install
  • Now let's compile Freeswitch
cd /usr/local/src/freeswitch# initialize dependencies linking./bootstrap.sh -j# generate make files of all the modules, check for missing 
dependencies and setup directory structure
./configure # compile freeswitch(this command compiles core and all other modules)make# copy compile freeswitch binaries to /usr/local/freeswitchmake install

Note: We have compiled Freeswitch with the default configuration so some modules might not be available with Freeswitch binaries. Refer to this file to check which modules are compiled /usr/local/src/freeswitch/modules.conf all the commented modules are ignored by default during compilation.

Compilation error example:

If you get any error during the compilation(make). Please check the logs and install the required dependency. For example:

# libpq-dev pkg is not installedmaking all mod_pgsql
make[4]: Entering directory '/usr/local/src/freeswitch/src/mod/databases/mod_pgsql'
Makefile:956: *** You must install libpq-dev to build mod_pgsql. Stop.
make[4]: Leaving directory '/usr/local/src/freeswitch/src/mod/databases/mod_pgsql'
make[3]: *** [Makefile:712: mod_pgsql-all] Error 1
make[3]: Leaving directory '/usr/local/src/freeswitch/src/mod'
make[2]: *** [Makefile:613: all-recursive] Error 1
make[2]: Leaving directory '/usr/local/src/freeswitch/src'
make[1]: *** [Makefile:3680: all-recursive] Error 1
make[1]: Leaving directory '/usr/local/src/freeswitch'
make: *** [Makefile:1432: all] Error

We can clearly see the error log which specifies the required dependency (Makefile:956: *** You must install libpq-dev to build mod_pgsql. Stop.)for this case is libpg-dev. We can fix this by simply installing it.

# Fix
apt-get install libpq-dev

Now run commands from bootstrap again

If you can't find a package using apt or yum please try to google it and resolve it.

You will see the following message when Freeswitch is installed successfully.

success
  • If you want to install Freeswitch sound use these commands. (~2GB download)

Freeswitch compiled directory structure

Compiled FreeSWITCH will be available at (/usr/local/freeswitch) directory structure of compiled Freeswitch is as follows:


exec_prefix: /usr/local/freeswitch
bindir: ${exec_prefix}/bin
confdir: /usr/local/freeswitch/conf
libdir: ${exec_prefix}/lib
datadir: /usr/local/freeswitch
localstatedir: /usr/local/freeswitch
includedir: /usr/local/freeswitch/include/freeswitch
certsdir: /usr/local/freeswitch/certs
dbdir: /usr/local/freeswitch/db
grammardir: /usr/local/freeswitch/grammar
htdocsdir: /usr/local/freeswitch/htdocs
fontsdir: /usr/local/freeswitch/fonts
logfiledir: /usr/local/freeswitch/log
modulesdir: /usr/local/freeswitch/mod
pkgconfigdir: ${exec_prefix}/lib/pkgconfig
recordingsdir: /usr/local/freeswitch/recordings
imagesdir: /usr/local/freeswitch/images
runtimedir: /usr/local/freeswitch/run
scriptdir: /usr/local/freeswitch/scripts
soundsdir: /usr/local/freeswitch/sounds
storagedir: /usr/local/freeswitch/storage
cachedir: /usr/local/freeswitch/cache

Start Freeswitch:

Freeswitch binaries are available in this directory /usr/local/freeswitch/bin. Execute Freeswitch binary now.

/usr/local/freeswitch/bin/freeswitch -nc# here -nc flag means run in background

Connect Freeswitch using fs_cli.

/usr/local/freeswitch/bin/fs_cli -r# here -r flag mean try to reconnect

Freeswitch CLI (fs_cli) connects with the Freeswitch using the ESL

You will see this screen after a successful start.

Type version in the fs_cli to check Freeswitch version

version

Type /exit to close from fs_cli.

We will learn more about how to use fs_cli and Freeswitch configuration in the upcoming blogs.

Links:

--

--

Chetan Pandey

A Software Engineer from New Delhi, India with interests in Data Science, GoLang, NodeJS, Python Development, Microservices, APIs, VOIP, Neural Networks, UI/UX