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

@rlorenz2417
Copy link

I'm running into these errors:

make[1]: Entering directory '/usr/local/src/freeswitch-1.10.7.-release'
CC src/libfreeswitch_la-switch_apr.lo
src/switch_apr.c: In function ‘switch_md5’:
src/switch_apr.c:1176:9: error: ‘MD5_Init’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
1176 | MD5_Init(&md5_context);
| ^~~~~~~~
In file included from src/switch_apr.c:79:
/usr/include/openssl/md5.h:49:27: note: declared here
49 | OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
| ^~~~~~~~
src/switch_apr.c:1177:9: error: ‘MD5_Update’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
1177 | MD5_Update(&md5_context, input, inputLen);
| ^~~~~~~~~~
In file included from src/switch_apr.c:79:
/usr/include/openssl/md5.h:50:27: note: declared here
50 | OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len);
| ^~~~~~~~~~
src/switch_apr.c:1178:9: error: ‘MD5_Final’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
1178 | MD5_Final(digest, &md5_context);
| ^~~~~~~~~
In file included from src/switch_apr.c:79:
/usr/include/openssl/md5.h:51:27: note: declared here
51 | OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c);
| ^~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:2153: src/libfreeswitch_la-switch_apr.lo] Error 1
make[1]: Leaving directory '/usr/local/src/freeswitch-1.10.7.-release'
make: *** [Makefile:1292: all] Error 2

@cyrenity
Copy link
Author

cyrenity commented Jun 28, 2023 via email

@anmol1991
Copy link

mod_spandsp_dsp.c:159:10: error: ‘V18_MODE_5BIT_4545’ undeclared (first use in this function)
159 | int r = V18_MODE_5BIT_4545;
| ^~~~~~~~~~~~~~~~~~
mod_spandsp_dsp.c:159:10: note: each undeclared identifier is reported only once for each function it appears in
mod_spandsp_dsp.c:165:8: error: ‘V18_MODE_5BIT_50’ undeclared (first use in this function)
165 | r = V18_MODE_5BIT_50;
| ^~~~~~~~~~~~~~~~
mod_spandsp_dsp.c: In function ‘spandsp_tdd_send_session’:
mod_spandsp_dsp.c:216:14: error: too few arguments to function ‘v18_init’
216 | tdd_state = v18_init(NULL, TRUE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, NULL);

I am getting this error, while building freeswitch-1.10.07 on U20.04 machine.

@aeschimannr
Copy link

Hello, i get the same error than @anmol1991 when make mod_spandsp.

@zhongcy
Copy link

zhongcy commented Jul 12, 2023

@anmol1991 @aeschimannr

git reset --hard 0d2e6ac65e0e8f53d652665a743015a88bf048d4

and remake

@cyrenity
Copy link
Author

Hello, i get the same error than @anmol1991 when make mod_spandsp.

which os and version you are installing on?

@aeschimannr
Copy link

aeschimannr commented Jul 13, 2023

i'm compiling on raspberry Pi OS Lite Debian Bullseye release 2023-05-03.
and with the freeswitch release v1.10.9

@aeschimannr
Copy link

I resolve the error with the following procedure
rm -rf spandsp
git clone https://github.com/freeswitch/spandsp
sudo git checkout -b finecode20230705 0d2e6ac65e0e8f53d652665a743015a88bf048d4
make and install

clean freeswitch repository
make and install again

@aeschimannr
Copy link

I'm not sure if this is the place to ask this question, but you seem to have experience with freeswitch.

I'd like freeswitch to boot into deamon. I have followed the procedure allowing Running as systemd service.
However, when I reboot and run fs_cli to see the status of sofia.
I get this:
Screenshot 2023-07-13 at 13 54 49
with a non-functional ip address

if I run the shutdown command in fs_cli and restart fs_cli, I get the following functional ip address:
Screenshot 2023-07-13 at 12 57 41

Do you have any idea what the problem is?

@cyrenity
Copy link
Author

You mean you get 127.0.0.1 on boot and if you restart using systemctl restart freeswitch then you get correct IP?

@aeschimannr
Copy link

yes, exactly

@cyrenity
Copy link
Author

Are you getting IP using DHCP or it's statically configured?

@aeschimannr
Copy link

i was using DHCP.

Editing dhcpcd.conf with the following cmd have resolve the issue.
sudo nano /etc/dhcpcd.conf
"interface [interface-name]
static ip_address=[ip-address]/[cidr-suffix]
static routers=[router-ip-address]
static domain_name_servers=[dns-address]"

many thanks!

@HDoIT
Copy link

HDoIT commented Sep 11, 2023

please help me this error:
make: *** No targets specified and no makefile found. Stop.

@glush
Copy link

glush commented Nov 26, 2023

To check SpanDSP installed run:

ldconfig && ldconfig -p | grep spandsp

instead of

ldconfig -p | grep spandsp

@swaman
Copy link

swaman commented Dec 29, 2023

Hi Sir, can you create the same instruction file of FreeSwitch and Unimrcp for RHEL 8. i was trying to install them but i was facing multiple type of errors. Please help me out.

@wheatforwood
Copy link

wheatforwood commented May 30, 2024

I've followed this guide on a fresh installation of Ubuntu 20.04 and I'm running into the following error on freeswitch compilation:

make[4]: Entering directory '/usr/local/src/freeswitch-1.10.7.-release/src/mod/endpoints/mod_verto'
CC mod_verto_la-mod_verto.lo
mod_verto.c:46:10: fatal error: ks.h: No such file or directory
46 | #include "ks.h"
| ^~~~~~

I have installed libks as recommended by the guide. And when I run sudo sh -c 'ldconfig && ldconfig -p' | grep libks I get
# sudo sh -c 'ldconfig && ldconfig -p' | grep libks
libks2.so.2 (libc6,x86-64) => /lib/libks2.so.2
libks2.so (libc6,x86-64) => /lib/libks2.so
libksba.so.8 (libc6,x86-64) => /lib/x86_64-linux-gnu/libksba.so.8

I have even tried changing the commit for libks thinking perhaps something changed. This commit was the most recent when others reported success, but it hasn't helped

git clone https://github.com/signalwire/libks.git /usr/local/src/libks && cd /usr/local/src/libks && git reset --hard 492532bcd27007113ee5ccedd5c65f33bbf9f4bc

Does anyone have any ideas on what to try from here?

Also note: I suggest adding libflite1 and flite-dev to the prerequisites. I needed these to build mod_flite

@cyrenity
Copy link
Author

If you installed libks after ./configure in FS directory then you would need to make clean and re-install FreeSWITCH

@wheatforwood
Copy link

Wow, thanks for such a fast rely @cyrenity! I installed libks first. But, just to be sure I ran

cd /usr/local/src/freeswitch-1.10.7.-release && make clean && ./configure && ./configure --enable-core-odbc-support --enable-core-pgsql-support && make && make install && make cd-sounds-install && make cd-moh-install

But, its still throwing an error in exactly the same way

mod_verto.c:46:10: fatal error: ks.h: No such file or directory
46 | #include "ks.h"
| ^~~~~~
compilation terminated.

@wheatforwood
Copy link

So, I went back to square one. Wiped the disk, reinstalled Ubuntu 20.04 and turned this whole thing into a one-liner for easy replicatability

# sudo to root to ensure its not possibly permissions
sudo su -
# stage modules.conf
vi /root/modules.conf
# one-liner install
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 wget vim libflite1 flite-dev && git clone https://github.com/signalwire/libks.git /usr/local/src/libks && cd /usr/local/src/libks && git reset --hard 492532bcd27007113ee5ccedd5c65f33bbf9f4bc && cmake . && make && sudo make install && git clone https://github.com/freeswitch/sofia-sip /usr/local/src/sofia-sip && cd /usr/local/src/sofia-sip && ./bootstrap.sh && ./configure && make && make install && git clone https://github.com/freeswitch/spandsp /usr/local/src/spandsp && cd /usr/local/src/spandsp && git reset --hard 0d2e6ac65e0e8f53d652665a743015a88bf048d4 && ./bootstrap.sh && ./configure && make && make install && wget -c https://files.freeswitch.org/releases/freeswitch/freeswitch-1.10.7.-release.tar.gz -P /usr/local/src && cd /usr/local/src && tar -zxvf freeswitch-1.10.7.-release.tar.gz && cd freeswitch-1.10.7.-release && cp -f /root/modules.conf /usr/local/src/freeswitch-1.10.7.-release/modules.conf && ./configure && ./configure --enable-core-odbc-support --enable-core-pgsql-support && make && make install && make cd-sounds-install && make cd-moh-install

Still getting

mod_verto.c:46:10: fatal error: ks.h: No such file or directory
46 | #include "ks.h"
| ^~~~~~
compilation terminated.

@cyrenity
Copy link
Author

cyrenity commented May 31, 2024 via email

@cyrenity
Copy link
Author

Do you have any specific requirement to install 1.10.7? ./configure output shows it's looking for libks 1.0, and the latest libks version is 2.0. Either upgrade FS or download v.1 of libks from github https://github.com/signalwire/libks/tags

@wheatforwood
Copy link

@cyrenity Thank you so much! This is very helpful! I do have a specific need for 1.10.7. I'll install the v1.8.3 tag for libks and see how things go!

@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

@skalogirou
Copy link

skalogirou commented Aug 1, 2024

@cyrenity Thanks for your post. It's very detailed and helpful. I managed to install it but when I run Freeswitch Sofia module is not loaded. I get the following error.

2024-08-01 10:45:41.340290 0.00% [CRIT] switch_loadable_module.c:1754 Error Loading module /usr/local/freeswitch/mod/mod_sofia.so **/usr/local/freeswitch/mod/mod_sofia.so: undefined symbol: tptag_socket_keepalive**

During make I got error on making mod_av and I commented on modules.conf . Is that has anything to do with the error?

The only relevant post I found is signalwire/freeswitch#861 . But I installed latest versions of everything

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