How to install FreeSWITCH on Ubuntu 20.04/18.04

How to install FreeSWITCH on Ubuntu 20.04/18.04

FreeSWITCH is an open-source communication platform that allows users to build scalable and customizable voice, video, and messaging applications. It can be used to create PBX systems, conference bridges, and call centers. In this guide, we will walk you through the step-by-step process of installing FreeSWITCH on Ubuntu 20.04 or 18.04.

FreeSWITCH is an open-source telephony platform that can be installed on Ubuntu to create a communication system that supports a wide range of protocols and applications. Here is a metadata description of how to install FreeSWITCH on Ubuntu:

Prerequisites: Before installing FreeSWITCH, you should ensure that your Ubuntu system meets the minimum system requirements, including having a 64-bit processor and at least 2GB of RAM. You should also make sure that your Ubuntu system is up to date and has all the necessary packages and dependencies installed.

Features of FreeSWITCH

  • Basic IP/PBX features
  • Runs on Windows, Linux and FreeBSD
  • IVR API
  • Call Recordings
  • Call Forwarding
  • High Performance Core engine
  • WebRTC support
  • Automated Receiving or Answering Machine
  • Customized Ring Back Tones

Prerequisites

Make sure PostgreSQL Server version 12 is installed and running before proceeding this article.

Install following FreeSWITCH dependencies (Ubuntu 18.04 LTS) and refer to (Ubuntu 22.04 LTS)

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

Install following FreeSWITCH dependencies (Ubuntu 20.04 LTS) and refer to (Ubuntu 22.04 LTS)

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 lua5.2 lua5.2-doc libreadline-dev

Installation Steps

FreeSWITCH v.1.10.5 requires sofia-sip and spandsp libraries to be installed seperately, in order to install these libs pls follow these instructions

Install libspandsp3

Run following command to Download and Install libspandsp3

cd /usr/local/src/
wget "https://github.com/freeswitch/spandsp/archive/master.tar.gz" -O spandsp.tar.gz
tar -xvf spandsp.tar.gz
cd spandsp-master
./bootstrap.sh && ./configure && make && make install
Install sofia-sip

Run following command to Download and Install sofia-sip

cd /usr/local/src/
wget "https://github.com/freeswitch/sofia-sip/archive/master.tar.gz" -O sofia-sip.tar.gz
tar -xvf sofia-sip.tar.gz
cd sofia-sip-master
./bootstrap.sh && ./configure && make && make install
Locate the given line
case PGRES_COPY_OUT:
case PGRES_COPY_IN:
and Paste following under it
case PGRES_PIPELINE_SYNC:
case PGRES_PIPELINE_ABORTED:
Install Lua Module
cp /usr/include/lua5.2/*.h  /usr/local/src/freeswitch-1.10.5.-release/src/mod/languages/mod_lua/
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.2.so /usr/lib/x86_64-linux-gnu/liblua.so

Download FreeSWITCH Release 1.10.5 source

cd /usr/local/src/
wget https://files.freeswitch.org/releases/freeswitch/freeswitch-1.10.5.-release.tar.gz
tar -zxvf freeswitch-1.10.5.-release.tar.gz

FreeSWITCH 1.10.5 Installation

cd freeswitch-1.10.5.-release

> open modules.conf in your favorite editor and remove or comment mod_signalwire

Now compile FreeSWITCH

./configure --enable-core-odbc-support --enable-core-pgsql-support
make
make install
make cd-sounds-install
make cd-moh-install

Configure FreeSWITCH

Setup softlinks and paths

ln -s /usr/local/freeswitch/conf /etc/freeswitch
ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin/fs_cli
ln -s /usr/local/freeswitch/bin/freeswitch /usr/sbin/freeswitch

Open `autoload_configs/switch.conf.xml` and add/modify `core-db-dsn` as showin in following line

Open `sip_profiles/internal.xml` and add/modify `odbc-dsn` param

Open `vars.xml` and make following changes (external_rtp_ip and external_sip_ip value must be `${local_ip_v4}`)

Add non-root less privilieged system user for running FreeSWITCH daemon

groupadd freeswitch
adduser --quiet --system --home /usr/local/freeswitch --gecos 'FreeSWITCH open source softswitch' --ingroup freeswitch freeswitch --disabled-password
chown -R freeswitch:freeswitch /usr/local/freeswitch/
chmod -R ug=rwX,o= /usr/local/freeswitch/
chmod -R u=rwx,g=rx /usr/local/freeswitch/bin/*

Setup systemd FreeSWITCH service

Open `/etc/systemd/system/freeswitch.service` in your favorite editor and paste following contents

[Unit]
Description=freeswitch
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

Now run following command to reload systemd dameon

systemctl daemon-reload

Enable FreeSWITCH service to start on boot

systemctl enable freeswitch

Start the FreeSWITCH Daemon

systemctl start freeswitch

Check if daemon is loaded successfully

systemctl status freeswitch

Important last step

Before considering your installation final, make sure to add following `crontab` entry for time synchronization

(This will make sure that time in cdr, console and logfiles is correct)

#synchronizes FS internal clock with system clock every night at 0100 hours

1 0 * * * /usr/bin/fs_cli -x 'fsctl sync_clock'

Follow us TwitterFacebookLinkedIn

Open Source Listing

Previous Post
Next Post

Comments

Best Open Source PBX Software of 2022 - Open Source Listing

[…] allowing developers to customize and integrate it with their own applications and services. FreeSWITCH supports a wide range of communication standards and protocols, making it a versatile and flexible […]

Leave a Reply