How to install FreeSWITCH on Ubuntu 22.04
FreeSWITCH
FreeSWITCH is an open-source, highly versatile telecommunication platform that empowers the creation and management of various real-time voice, video, and messaging communication applications. It is known for its flexibility and scalability, making it a preferred choice for developers and businesses looking to build and customize solutions for voice-over-IP (VoIP), conferencing, and other telecommunication services. FreeSWITCH offers a wide range of features, including support for various VoIP protocols, advanced call routing, multi-platform compatibility, and extensive integration options, contributing to its popularity in the telecommunications industry.
Prerequisites
Make sure [PostgreSQL Server version 16 is installed] and runnning before proceeding this article.
Install following FreeSWITCH dependencies (Ubuntu 22.04 LTS) and for (Ubuntu 18.04/20.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 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
Configure Timezone
dpkg-reconfigure tzdata
crontab -e
# Run ntp date command every 30 minutes
*/30 * * * * ntpdate 192.168.1.11
FreeSWITCH v.1.10.5 requires sofia-sip and spandsp libraries to be installed seperately, in order to install these libs please follow these instructions
Install libspandsp3
Run following command to Download and Install spandsp
git clone https://github.com/freeswitch/spandsp.git
cd spandsp/
git checkout 0d2e6ac
./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
Download FreeSWITCH
Download FreeSWITCH Release 1.10.10 source
cd /usr/local/src/
wget https://files.freeswitch.org/releases/freeswitch/freeswitch-1.10.10.-release.tar.gz
tar -zxvf freeswitch-1.10.10.-release.tar.gz
Install Lua Module
cp /usr/include/lua5.2/*.h /usr/local/src/freeswitch-1.10.10.-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
FreeSWITCH 1.10.10 Installation
cd freeswitch-1.10.10.-release
> open modules.conf in your favorite editor and remove or comment mod_signalwire and mod_verto
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
<param name="core-db-dsn" value="dsn:username:password"/>
Open `sip_profiles/internal.xml` and add/modify `odbc-dsn` param as showin in following line
<param name="odbc-dsn" value="dsn:username:password"/>
Open `vars.xml` and make following changes (external\_rtp\_ip and external\_sip\_ip value must be `$${local_ip_v4}`)
<X-PRE-PROCESS cmd="stun-set" data="external_rtp_ip=$${local_ip_v4}"/>
<X-PRE-PROCESS cmd="stun-set" data="external_sip_ip=$${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.service
Start the FreeSWITCH Daemon
systemctl start freeswitch.service
Check if daemon is loaded successfully
systemctl status freeswitch.service
Check if freeswitch not started
ldconfig
Important last step
FreeSWITCH uses its own internal clock which may go out of sync due to highload or various other reasons. In order to keep the FS internal clock synced with systems clock use FreeSWITCHs api `fsctl sync_clock`
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'
Conclusion
In conclusion, FreeSWITCH stands as a robust and versatile open-source telecommunication platform that enables the creation of customizable and scalable communication solutions. With support for a wide range of VoIP protocols, advanced call routing, and integration options, FreeSWITCH empowers developers and businesses to build and manage various real-time voice, video, and messaging applications. Its flexibility and rich feature set have established it as a valuable tool within the telecommunications industry, catering to a diverse array of communication needs and preferences.
Well!! very helpful….. best of luck