Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • 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.7 on Ubuntu 20.04 LTS

Installing FreeSWITCH 1.10.X on Ubuntu 18.04 | Ubuntu 20.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

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

$ 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

$ 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

$ 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

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

@bluepoet2k
Copy link

Maybe I have that in another config file as well. Or should that all be from the freeswitch.service file?

@cyrenity
Copy link
Author

This should not be the case, there is only one /etc/systemd/system/freeswitch.service file

@bluepoet2k
Copy link

Guess I will need to figure out then how to make a user with the right permissions or find out where it is getting the www-data name at. Thank you.

@bluepoet2k
Copy link

Okay - I got it to work I think - I went into the freeswitch.service file - took out the environment options and hard entered the information. Re-ran everything and it went with no issues.

I basically ran it like this ExecStart=/usr/local/freeswitch/bin/freeswitch -u freeswitch -g freeswitch -ncwait -nonat

Dunno why that worked but it did.

@bluepoet2k
Copy link

bluepoet2k commented Feb 23, 2022 via email

@cyrenity
Copy link
Author

for fusionpbx you really don't need to manually install FreeSWITCH, just run the fusion PBX installation script and it will take care of the FreeSWITCH installation

@bluepoet2k
Copy link

I realized that this morning and have things up and running. The last hurdle now is to see if the Avaya 9611G phones we acquired will provision in fusions. I do appreciate all your help.

@sahil-ecosmob
Copy link

Hello. I am installing freeswitch in ubuntu 20.04 LTS. Make and make install ran successfully. but when starting Freeswitch, I get this error.
/freeswitch: error while loading shared libraries: libsofia-sip-ua.so.0: cannot open shared object file: No such file or directory

@cyrenity
Copy link
Author

You need to make sure Sofia is installed successfully

@jeremy-immersitech
Copy link

@sahil-ecosmob You may need to run ldconfig by itself after installing sofia. That worked for me.

@victor-shelepen
Copy link

During signalwire-c installation I receive the following error:

[ 47%] Building C object CMakeFiles/signalwire_client.dir/src/transport/websocket.c.o
/usr/local/src/signalwire-c/src/transport/websocket.c: In function ‘__connect_socket’:
/usr/local/src/signalwire-c/src/transport/websocket.c:308:36: warning: ‘:swclt’ directive output may be truncated writing 6 bytes into a region of size between 0 and 254 [-Wformat-truncation=]
  308 |  snprintf(buf, sizeof(buf), "/%s:%s:swclt", ctx->info.path, ctx->info.address);
      |                                    ^~~~~~
/usr/local/src/signalwire-c/src/transport/websocket.c:308:2: note: ‘snprintf’ output between 9 and 263 bytes into a destination of size 256
  308 |  snprintf(buf, sizeof(buf), "/%s:%s:swclt", ctx->info.path, ctx->info.address);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 50%] Linking C shared library libsignalwire_client.so
[ 50%] Built target signalwire_client
Scanning dependencies of target swclt_bench
[ 52%] Building C object swclt_bench/CMakeFiles/swclt_bench.dir/main.c.o
[ 55%] Linking C executable swclt_bench
[ 55%] Built target swclt_bench
[ 57%] Generating C unity source swclt_test/cotire/swclt_test_C_unity.c
[ 60%] Generating C prefix source swclt_test/cotire/swclt_test_C_prefix.c
[ 63%] Generating C prefix header swclt_test/cotire/swclt_test_C_prefix.h
[ 65%] Building C precompiled header swclt_test/cotire/swclt_test_C_prefix.h.gch
Scanning dependencies of target swclt_test
[ 68%] Building C object swclt_test/CMakeFiles/swclt_test.dir/cases/callback.c.o
[ 71%] Building C object swclt_test/CMakeFiles/swclt_test.dir/cases/command.c.o

I've created an issue here.

@hrg92
Copy link

hrg92 commented Jan 20, 2023

Hello

When I start the service it gives me the following error.

image

I share the file freeswitch.service

image

What could cause the problem?

Thanks

@rolandwu777
Copy link

rolandwu777 commented Feb 5, 2023

@cyrenity, in your steps, there is a typo [signwalwire-c]
"sudo git clone https://github.com/signalwire/signalwire-c.git /usr/local/src/signwalwire-c"

Thanks!

@dinesh1310
Copy link

image

facing this issue while configuring freeswitch from openssl v 1.1.1 to v 3.0.8.. error while runing ./configure file

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

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