FreeSWITCH is a software defined telecom stack that runs on any commodity hardware. FreeSWITCH can handle voice, video and text communication and support all popullar VoIP protocols. FreeSWITCH is flexible and modular, and can be used in any way you can imagine
This guide demonstrates how to get it install FreeSWITCH and get it up and running on a Ubuntu 20.04 LTS machine
To follow along with this guide, you need one Ubuntu 20.04 LTS server which has prerequisite packages installed and configured. In order to install required packages issue following command
$ sudo apt install --yes build-essential pkg-config uuid-dev zlib1g-dev libjpeg-dev libsqlite3-dev libcurl4-openssl-dev \
libpcre3-dev libspeexdsp-dev libldns-dev libedit-dev libtiff5-dev yasm libopus-dev libsndfile1-dev unzip \
libavformat-dev libswscale-dev libavresample-dev liblua5.2-dev liblua5.2 cmake libpq-dev \
unixodbc-dev autoconf automake ntpdate libxml2-dev libpq-dev libpq5 sngrep
$ sudo apt install --yes build-essential pkg-config uuid-dev zlib1g-dev libjpeg-dev libsqlite3-dev libcurl4-openssl-dev \
libpcre3-dev libspeexdsp-dev libldns-dev libedit-dev libtiff5-dev yasm libopus-dev libsndfile1-dev unzip \
libavformat-dev libswscale-dev libavresample-dev liblua5.2-dev liblua5.2-0 cmake libpq-dev \
unixodbc-dev autoconf automake ntpdate libxml2-dev libpq-dev libpq5 sngrep
sudo apt install --yes build-essential pkg-config uuid-dev zlib1g-dev libjpeg-dev libsqlite3-dev libcurl4-openssl-dev \
libpcre3-dev libspeexdsp-dev libldns-dev libedit-dev libtiff5-dev yasm libopus-dev libsndfile1-dev unzip \
libavformat-dev libswscale-dev liblua5.2-dev liblua5.2-0 cmake libpq-dev \
unixodbc-dev autoconf automake ntpdate libxml2-dev libpq-dev libpq5 sngrep
In order to install libks
First, download latest code from github using following command
$ sudo git clone https://github.com/signalwire/libks.git /usr/local/src/libks
Now run following commands in sequence to install the library
$ cd /usr/local/src/libks
$ sudo cmake .
$ sudo make && sudo make install
To verify if libks
is installed correctly in your system, run following command
$ sudo sh -c 'ldconfig && ldconfig -p' | grep libks
In Order to install libsignalwire
Run following command to download latest code from github
$ sudo git clone https://github.com/signalwire/signalwire-c.git /usr/local/src/signalwire-c
Now run following commands in sequence to install the library
$ cd /usr/local/src/signalwire-c
$ sudo cmake .
$ sudo make && sudo make install
To verify if libsignalwire-client
is installed correctly in your system, run following command
$ sudo sh -c 'ldconfig && ldconfig -p' | grep signalwire
Starting from FreeSWITCH version 1.10.4 You have to Download, Compile and install
sofia-sip
andspandsp
libraries separately
In order to install Sofia-Sip library, you need to download the latest code from FreeSWITCH’s official Packages repository
Clone the official Sofia-Sip repository into /usr/local/src
directory
$ sudo git clone https://github.com/freeswitch/sofia-sip /usr/local/src/sofia-sip
Now run following commands in sequence to install the library
$ cd /usr/local/src/sofia-sip
$ sudo ./bootstrap.sh
$ sudo ./configure
$ sudo make && sudo make install
To verify if Sofia-Sip library is installed correctly in your system, run following command
$ sudo sh -c 'ldconfig && ldconfig -p' | grep sofia
If libsofia-sip
is not installed, there will be no output. If it is installed, you will get a line for each version available.
Clone the SpanDSP repository from FreeSWITCH packages repository into /usr/local/src
directory
$ sudo git clone https://github.com/freeswitch/spandsp /usr/local/src/spandsp
Now run following commands in sequence to install the library
$ cd /usr/local/src/spandsp
$ sudo ./bootstrap.sh
$ sudo ./configure
$ sudo make && sudo make install
To verify if SpanDSP library is installed correctly in your system, run following command
$ sudo sh -c 'ldconfig && ldconfig -p' | grep spandsp
If libspandsp
is not installed, there will be no output. If it is installed, you will get a line for each version available.
You are now ready to install FreeSWITCH
Download the FreeSWITCH 1.10.7 release file into /usr/local/src
directory
$ sudo wget -c https://files.freeswitch.org/releases/freeswitch/freeswitch-1.10.7.-release.tar.gz -P /usr/local/src
Extract the release file
$ cd /usr/local/src
$ sudo tar -zxvf freeswitch-1.10.7.-release.tar.gz
$ cd freeswitch-1.10.7.-release
Run the configure script
$ sudo ./configure
Note: FreeSWITCH uses SQLite by default for it’s core database although support for other database options Like PostgreSQL, ODBC exists. If you want to enable Postgres or ODBC support than you need to run the
./configure
script with following arguments
$ sudo ./configure --enable-core-odbc-support --enable-core-pgsql-support
Now you are ready to compile and install the FreeSWITCH, run following commands in sequence
$ sudo make
$ sudo make install
To install sound and music on hold run following command
$ sudo make cd-sounds-install
$ sudo make cd-moh-install
FreeSWITCH is now installed and you can confirm it by running sudo freeswitch -nonat
from your terminal
By default, FreeSWITCH will install it’s binaries and configurations in /usr/local/bin
and /usr/local/freeswitch
, to make them available system wide you can create following symlinks
$ sudo ln -s /usr/local/freeswitch/conf /etc/freeswitch
$ sudo ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin/fs_cli
$ sudo ln -s /usr/local/freeswitch/bin/freeswitch /usr/sbin/freeswitch
Create a unprivileged system user for running FreeSWITCH daemon
$ sudo groupadd freeswitch
$ sudo adduser --quiet --system --home /usr/local/freeswitch --gecos 'FreeSWITCH open source softswitch' --ingroup freeswitch freeswitch --disabled-password
$ sudo chown -R freeswitch:freeswitch /usr/local/freeswitch/
$ sudo chmod -R ug=rwX,o= /usr/local/freeswitch/
$ sudo chmod -R u=rwx,g=rx /usr/local/freeswitch/bin/*
In order to run FreeSWITCH in background using systemctl, open /etc/systemd/system/freeswitch.service
in your favorite editor and copy following content into it
[Unit]
Description=FreeSWITCH open source softswitch
Wants=network-online.target Requires=network.target local-fs.target
After=network.target network-online.target local-fs.target
[Service]
; service
Type=forking
PIDFile=/usr/local/freeswitch/run/freeswitch.pid
Environment="DAEMON_OPTS=-nonat"
Environment="USER=freeswitch"
Environment="GROUP=freeswitch"
EnvironmentFile=-/etc/default/freeswitch
ExecStartPre=/bin/chown -R ${USER}:${GROUP} /usr/local/freeswitch
ExecStart=/usr/local/freeswitch/bin/freeswitch -u ${USER} -g ${GROUP} -ncwait ${DAEMON_OPTS}
TimeoutSec=45s
Restart=always
[Install]
WantedBy=multi-user.target
Reload the systemctl daemon
$ sudo systemctl daemon-reload
Start the FreeSWITCH Service
$ sudo systemctl start freeswitch
Check if daemon has start successfully
$ sudo systemctl status freeswitch
The fs_cli
program is a Command-Line Interface that allows a user to connect to a running FreeSWITCH™ instance. The fs_cli
program can connect to the FreeSWITCH™ process on the local machine or on a remote system. (Network connectivity to the remote system is, of course, required.)
I am having a problem getting the service to work. Did all the commands you mentioned above, no errors, everything appears to have gone in with no issues but when I try to run the start command it comes back and says it exited with an error code.
sudo systemctl start freeswitch
Job for freeswitch.service failed because the control process exited with error code.
See "systemctl status freeswitch.service" and "journalctl -xe" for details.
I then ran the status command and it says the following:
sudo systemctl status freeswitch.service
● freeswitch.service - FreeSWITCH open source softswitch
Loaded: loaded (/etc/systemd/system/freeswitch.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-02-23 19:15:40 UTC; 18s ago
Process: 122330 ExecStartPre=/bin/chown -R ${USER}:${GROUP} /usr/local/freeswitch (code=exited, status=0/SUCCESS)
Process: 122331 ExecStart=/usr/local/freeswitch/bin/freeswitch -u ${USER} -g ${GROUP} -ncwait ${DAEMON_OPTS} (code=exited, status=1/FAILURE)
Feb 23 19:15:40 freeswitch systemd[1]: freeswitch.service: Scheduled restart job, restart counter is at 5.
Feb 23 19:15:40 freeswitch systemd[1]: Stopped FreeSWITCH open source softswitch.
Feb 23 19:15:40 freeswitch systemd[1]: freeswitch.service: Start request repeated too quickly.
Feb 23 19:15:40 freeswitch systemd[1]: freeswitch.service: Failed with result 'exit-code'.
Feb 23 19:15:40 freeswitch systemd[1]: Failed to start FreeSWITCH open source softswitch.
I then ran the journal command and go the following:
A stop job for unit freeswitch.service has finished.
-- The job identifier is 8694 and the job result is done.
Feb 23 19:23:48 freeswitch systemd[1]: Starting FreeSWITCH open source softswitch...
-- Subject: A start job for unit freeswitch.service has begun execution
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- A start job for unit freeswitch.service has begun execution.
-- The job identifier is 8694.
Feb 23 19:23:48 freeswitch freeswitch[122518]: Unknown option '-nonat -ncwait -u www-data -g www-data -run /var/run/freeswitch', see '/usr/local/freeswitch/bi>
Feb 23 19:23:48 freeswitch systemd[1]: freeswitch.service: Control process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- An ExecStart= process belonging to unit freeswitch.service has exited.
-- The process' exit code is 'exited' and its exit status is 1.
Feb 23 19:23:48 freeswitch systemd[1]: freeswitch.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- The unit freeswitch.service has entered the 'failed' state with result 'exit-code'.
Feb 23 19:23:48 freeswitch systemd[1]: Failed to start FreeSWITCH open source softswitch.
-- Subject: A start job for unit freeswitch.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- A start job for unit freeswitch.service has finished with a failure.
-- The job identifier is 8694 and the job result is failed.
Feb 23 19:23:49 freeswitch systemd[1]: freeswitch.service: Scheduled restart job, restart counter is at 5.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- Automatic restarting of the unit freeswitch.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Feb 23 19:23:49 freeswitch systemd[1]: Stopped FreeSWITCH open source softswitch.
-- Subject: A stop job for unit freeswitch.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- A stop job for unit freeswitch.service has finished.
-- The job identifier is 8776 and the job result is done.
Feb 23 19:23:49 freeswitch systemd[1]: freeswitch.service: Start request repeated too quickly.
Feb 23 19:23:49 freeswitch systemd[1]: freeswitch.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- The unit freeswitch.service has entered the 'failed' state with result 'exit-code'.
Feb 23 19:23:49 freeswitch systemd[1]: Failed to start FreeSWITCH open source softswitch.
-- Subject: A start job for unit freeswitch.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- A start job for unit freeswitch.service has finished with a failure.
-- The job identifier is 8776 and the job result is failed.
Feb 23 19:23:57 freeswitch sudo[122519]: ap : TTY=pts/2 ; PWD=/usr/local ; USER=root ; COMMAND=/usr/bin/journalctl -xe
Feb 23 19:23:57 freeswitch sudo[122519]: pam_unix(sudo:session): session opened for user root by ap(uid=0)
ap@freeswitch:/usr/local$
ap@freeswitch:/usr/local$ sudo journalctl -xe
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- A start job for unit freeswitch.service has begun execution.
-- The job identifier is 8694.
Feb 23 19:23:48 freeswitch freeswitch[122518]: Unknown option '-nonat -ncwait -u www-data -g www-data -run /var/run/freeswitch', see '/usr/local/freeswitch/bi>
Feb 23 19:23:48 freeswitch systemd[1]: freeswitch.service: Control process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- An ExecStart= process belonging to unit freeswitch.service has exited.
-- The process' exit code is 'exited' and its exit status is 1.
Feb 23 19:23:48 freeswitch systemd[1]: freeswitch.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- The unit freeswitch.service has entered the 'failed' state with result 'exit-code'.
Feb 23 19:23:48 freeswitch systemd[1]: Failed to start FreeSWITCH open source softswitch.
-- Subject: A start job for unit freeswitch.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- A start job for unit freeswitch.service has finished with a failure.
-- The job identifier is 8694 and the job result is failed.
Feb 23 19:23:49 freeswitch systemd[1]: freeswitch.service: Scheduled restart job, restart counter is at 5.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- Automatic restarting of the unit freeswitch.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Feb 23 19:23:49 freeswitch systemd[1]: Stopped FreeSWITCH open source softswitch.
-- Subject: A stop job for unit freeswitch.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- A stop job for unit freeswitch.service has finished.
-- The job identifier is 8776 and the job result is done.
Feb 23 19:23:49 freeswitch systemd[1]: freeswitch.service: Start request repeated too quickly.
Feb 23 19:23:49 freeswitch systemd[1]: freeswitch.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- The unit freeswitch.service has entered the 'failed' state with result 'exit-code'.
Feb 23 19:23:49 freeswitch systemd[1]: Failed to start FreeSWITCH open source softswitch.
-- Subject: A start job for unit freeswitch.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- A start job for unit freeswitch.service has finished with a failure.
-- The job identifier is 8776 and the job result is failed.
Any suggestions as to what I should try next would be greatly appreciated. Thanks.