Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cyrenity/96cc1ad7979b719b1c684f90aa0f526d to your computer and use it in GitHub Desktop.
Save cyrenity/96cc1ad7979b719b1c684f90aa0f526d to your computer and use it in GitHub Desktop.
Install FreeSWITCH 1.10.x on Ubuntu 18.04 | 20.04 | 22.04 LTS

Installing FreeSWITCH 1.10.X on Ubuntu 18.04 | 20.04 | 22.04 LTS

Introduction

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

Prerequisites

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

Ubuntu 18.04 LTS
$ 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
Ubuntu 20.04 LTS
$ 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
Ubuntu 22.04 LTS
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

Install pre-requisites and libraries

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 and spandsp libraries separately

In order to install Sofia-Sip library, you need to download the latest code from FreeSWITCH’s official Packages repository

Installing Sofia-Sip library

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.

Installing SpanDSP library

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

Installing 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

Post install setup

Create Symlinks (Optional)

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 an unprivileged user

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/*
Running as systemd service

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
Command Line interface

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.)

@wheatforwood
Copy link

@cyrenity Many thanks this works!

Some notes I've collected in case they are useful to anyone else:

  • Ubuntu 22.04 requires FS 1.10.10+ due to OpenSSL3

  • FS 1.10.9 and lower requires that you to use sudo git clone -bv1.8.3 https://github.com/signalwire/libks.git /usr/local/src/libks instead of sudo git clone https://github.com/signalwire/libks.git /usr/local/src/libks because they require libks v1 and the default branch is now v2.

  • libflite1 and flite-dev are required if you want to build mod_flite

@srmd-tl
Copy link

srmd-tl commented May 31, 2024

@cyrenity I am on ubuntu 24.04
cloned and make and install latest release of libk (worked fine)
cloned and make latest FS (1.10.11) got the error
make[4]: Entering directory '/usr/local/src/freeswitch-1.10.11.-release/src/mod/applications/mod_av'
CC libavmod_la-avformat.lo
avformat.c: In function ‘mod_avformat_alloc_output_context2’:
avformat.c:458:23: error: ‘const struct AVOutputFormat’ has no member named ‘priv_data_size’
458 | if (s->oformat->priv_data_size > 0) {
| ^~
avformat.c:459:53: error: ‘const struct AVOutputFormat’ has no member named ‘priv_data_size’
459 | s->priv_data = av_mallocz(s->oformat->priv_data_size);
| ^~
avformat.c: In function ‘add_stream’:
avformat.c:624:25: error: ‘ticks_per_frame’ is deprecated [-Werror=deprecated-declarations]
624 | c->ticks_per_frame = 2;
| ^
In file included from avformat.c:37:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:579:9: note: declared here
579 | int ticks_per_frame;
| ^~~~~~~~~~~~~~~
avformat.c: In function ‘av_file_read_video’:
avformat.c:3206:17: error: ‘ticks_per_frame’ is deprecated [-Werror=deprecated-declarations]
3206 | ticks = cp ? cp->repeat_pict + 1 : c->ticks_per_frame;
| ^~~~~
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:579:9: note: declared here
579 | int ticks_per_frame;
| ^~~~~~~~~~~~~~~
avformat.c:3212:25: error: ‘ticks_per_frame’ is deprecated [-Werror=deprecated-declarations]
3212 | context->video_start_time, ticks, c ? c->ticks_per_frame : -1, st->time_base.num, st->time_base.den, c ? c->time_base.num : -1, c ? c->time_base.den : -1,
| ^~~~~~~
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:579:9: note: declared here
579 | int ticks_per_frame;

@cyrenity
Copy link
Author

cyrenity commented Jun 1, 2024

@cyrenity I am on ubuntu 24.04 cloned and make and install latest release of libk (worked fine) cloned and make latest FS (1.10.11) got the error make[4]: Entering directory '/usr/local/src/freeswitch-1.10.11.-release/src/mod/applications/mod_av' CC libavmod_la-avformat.lo avformat.c: In function ‘mod_avformat_alloc_output_context2’: avformat.c:458:23: error: ‘const struct AVOutputFormat’ has no member

Try installing an older version of ffmpeg. Follow this link for more details

signalwire/freeswitch#2202

@rajujnvgupta
Copy link

please below link to install.
this

@srmd-tl
Copy link

srmd-tl commented Jun 4, 2024

@cyrenity i have tried by downgrading ffmpeg and it got with other dependency issues.
So, i shifted to ubuntu 22 and now using FS 1.10.10.
For FS 1.10.10 we need to install older 1.x version of both dsp,libk and signalwire

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment