Skip to main content

Kamailio v5 with Siremis GUI v5 on Debian v9,v10 and v11 MariaDB Apache Install Guide

Kamailio® is an Open Source SIP Server released under GPL, able to handle thousands of call setups per second. Kamailio can be used to build large platforms for VoIP and realtime communications – presence, WebRTC, Instant messaging and other applications.  Moreover, it can be easily used for scaling up SIP-to-PSTN gateways, PBX systems or media servers like Asterisk™, FreeSWITCH™ etc.

Siremis is a web management interface for Kamailio.  It allows configuration of user profiles, routing rules, view accounting, registered phones, display charts etc.

This guide was tested using:

Debian v9 (Stretch) x64
Kamailio v5
Siremis v5

Pre-install

apt update && apt upgrade
apt install dbus nano sudo curl git lsb-release mariadb-server apache2

PHP

apt install php php-mysql php-gd php-curl php-xml php-xmlrpc php-pear

Set PHP timezone.

## FIND YOUR TIMEZONE
tzselect
nano +924 /etc/php/7.0/apache2/php.ini
#For example
date.timezone = America/Vancouver
systemctl restart apache2

XML_RPC

cd /usr/src
# wget http://pear.php.net/get/XML_RPC-1.5.5.tgz
# If above link is not working try this link
wget https://src.fedoraproject.org/repo/pkgs/php-pear/XML_RPC-1.5.5.tgz/\
02f9b1a27636527ddf6661e545799d45/XML_RPC-1.5.5.tgz
pear upgrade XML_RPC-1.5.5.tgz 

Disable Firewall

It is sometimes helpful to disable the firewall during installation.

systemctl disable firewalld
systemctl disable iptables
systemctl stop firewalld
systemctl stop iptables

System Timezone

## FIND YOUR TIMEZONE
tzselect

## SET TIMEZONE EXAMPLE
timedatectl set-timezone America/Vancouver

## CHECK TIMEZONE
​timedatectl status
systemctl restart rsyslog

Kamailio

wget -O- http://deb.kamailio.org/kamailiodebkey.gpg | sudo apt-key add -
echo "deb http://deb.kamailio.org/kamailio51 $(lsb_release -sc) main" >/etc/apt/sources.list.d/kamailio.list
apt update && apt install kamailio kamailio-mysql-modules kamailio-presence-modules kamailio-xml-modules

nano /etc/kamailio/kamctlrc and uncomment the DBENGINE and CHARSET lines as follows

DBENGINE=MYSQL
CHARSET="latin1"

Create Kamailio database

kamdbctl create

Answer y to everything.

Configure Kamailio

cd /etc/kamailio/
cp kamailio.cfg kamailio.cfg.orig

Replace kamilio.cfg with this pre-configured kamailio.cfg file.  Alternatively, edit kamailio.cfg manually as follows.

The top of the file should look like the following:

#!KAMAILIO
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
#!define WITH_PRESENCE
##!define WITH_NAT
##!define WITH_TLS
#!define WITH_ACCDB
#!define WITH_XMLRPC
#!define WITH_JSONRPC
##!define WITH_DEBUG
Add this part around line #250 in with the other loadmodule statements
# -- for siremis CDRs --------------
loadmodule "rtimer.so"
loadmodule "sqlops.so"

Add this part around line 290

# -- For XMLRPC --------------------
#!ifdef WITH_XMLRPC
loadmodule "xmlrpc.so"
#!endif

# -- For JSONRPC -------------------
#!ifdef WITH_JSONRPC
loadmodule "jsonrpcs.so"
#!endif

Add the following around line 450

#!ifdef WITH_XMLRPC
# ----- xmlrpc params -----
modparam("xmlrpc", "route", "XMLRPC")
modparam("xmlrpc", "url_match", "^/RPC")
#!endif

#!ifdef WITH_JSONRPC
# ----- jsonrpcs params -----
modparam("jsonrpcs", "dgram_socket", "/var/run/kamailio/kamailio_rpc.sock")
modparam("jsonrpcs", "dgram_mode", 0666)
#!endif
Add the following around line #470 at the end of the modparam section before the routing logic section.
# -- for siremis CDRs --------------
modparam("rtimer", "timer", "name=cdr;interval=300;mode=1;")
modparam("rtimer", "exec", "timer=cdr;route=CDRS")
modparam("sqlops", "sqlcon", "cb=>mysql://kamailio:kamailiorw@localhost/kamailio")
Finally, add this at the end of the routing section around line #910
# ======================================================
# Populate CDRs Table of Siremis
# ======================================================
route[CDRS] {
    sql_query("cb","call kamailio_cdrs()","rb");
    sql_query("cb","call kamailio_rating('default')","rb");
    }


# XMLRPC routing
#!ifdef WITH_XMLRPC
route[XMLRPC] {
    # allow XMLRPC from localhost
    if ((method=="POST" || method=="GET")
            && (src_ip==127.0.0.1)) {
        # close connection only for xmlrpclib user agents (there is a bug in
        # xmlrpclib: it waits for EOF before interpreting the response).
        if ($hdr(User-Agent) =~ "xmlrpclib")
            set_reply_close();
        set_reply_no_connect();
        dispatch_rpc();
        exit;
    }
    send_reply("403", "Forbidden");
    exit;
}
#!endif
Pointing SIP clients to a FQDN instead of an IP address requires a local alias.  The commented out example is located around line #170 in /etc/kamailio/kamailio.cfg.   You can specify multiple aliases by repeating that line
/* add local domain aliases */
alias="your_server_fqdn"
alias="your_server_fqdn2"
systemctl restart kamailio

Siremis

cd /var/www
git clone https://github.com/asipto/siremis

Create apache config file.  

cat >> /etc/apache2/sites-available/siremis.conf << EOF
<VirtualHost *:80>

    #ServerName www.example.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog /var/log/apache2/error.log
    CustomLog /var/log/apache2/access.log combined

    Alias /siremis "/var/www/siremis/siremis"
    <Directory "/var/www/siremis/siremis">
    
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted

            <FilesMatch "\.xml$">
                Require all denied
            </FilesMatch>

            <FilesMatch "\.inc$">
                Require all denied
            </FilesMatch>

      </Directory>

</VirtualHost>
EOF
a2dissite 000-default
a2ensite siremis
a2enmod rewrite
systemctl restart apache2

Create Siremis configs and set permissions

cd /var/www/siremis
make prepare24
make chown

Create MySQL user

mysql -e "GRANT ALL PRIVILEGES ON siremis.* TO siremis@localhost IDENTIFIED BY 'siremisrw';"

Lock down the database

mysql_secure_installation

Answer Y to everything.

 

Run the web install wizard from a web browser at http://your_server_ip_or_fqdn/siremis

Kamailio® is an Open Source SIP Server released under GPL, able to handle thousands of call setups per second. Kamailio can be used to build large platforms for VoIP and realtime communications – presence, WebRTC, Instant messaging and other applications.  Moreover, it can be easily used for scaling up SIP-to-PSTN gateways, PBX systems or media servers like Asterisk™, FreeSWITCH™ etc.

Siremis is a web management interface for Kamailio.  It allows configuration of user profiles, routing rules, view accounting, registered phones, display charts etc.

This guide was tested using:

Debian v9 (Stretch) x64
Kamailio v5
Siremis v5

Pre-install

apt update && apt upgrade
apt install dbus nano sudo curl git lsb-release mariadb-server apache2

PHP

apt install php php-mysql php-gd php-curl php-xml php-xmlrpc php-pear

Set PHP timezone.

## FIND YOUR TIMEZONE
tzselect
nano +924 /etc/php/7.0/apache2/php.ini
#For example
date.timezone = America/Vancouver
systemctl restart apache2

XML_RPC

cd /usr/src
# wget http://pear.php.net/get/XML_RPC-1.5.5.tgz
# If above link is not working try this link
wget https://src.fedoraproject.org/repo/pkgs/php-pear/XML_RPC-1.5.5.tgz/\
02f9b1a27636527ddf6661e545799d45/XML_RPC-1.5.5.tgz
pear upgrade XML_RPC-1.5.5.tgz 

Disable Firewall

It is sometimes helpful to disable the firewall during installation.

systemctl disable firewalld
systemctl disable iptables
systemctl stop firewalld
systemctl stop iptables

System Timezone

## FIND YOUR TIMEZONE
tzselect

## SET TIMEZONE EXAMPLE
timedatectl set-timezone America/Vancouver

## CHECK TIMEZONE
​timedatectl status
systemctl restart rsyslog

Kamailio

wget -O- http://deb.kamailio.org/kamailiodebkey.gpg | sudo apt-key add -
echo "deb http://deb.kamailio.org/kamailio51 $(lsb_release -sc) main" >/etc/apt/sources.list.d/kamailio.list
apt update && apt install kamailio kamailio-mysql-modules kamailio-presence-modules kamailio-xml-modules

nano /etc/kamailio/kamctlrc and uncomment the DBENGINE and CHARSET lines as follows

DBENGINE=MYSQL
CHARSET="latin1"

Create Kamailio database

kamdbctl create

Answer y to everything.

Configure Kamailio

cd /etc/kamailio/
cp kamailio.cfg kamailio.cfg.orig

Replace kamilio.cfg with this pre-configured kamailio.cfg file.  Alternatively, edit kamailio.cfg manually as follows.

The top of the file should look like the following:

#!KAMAILIO
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
#!define WITH_PRESENCE
##!define WITH_NAT
##!define WITH_TLS
#!define WITH_ACCDB
#!define WITH_XMLRPC
#!define WITH_JSONRPC
##!define WITH_DEBUG
Add this part around line #250 in with the other loadmodule statements
# -- for siremis CDRs --------------
loadmodule "rtimer.so"
loadmodule "sqlops.so"

Add this part around line 290

# -- For XMLRPC --------------------
#!ifdef WITH_XMLRPC
loadmodule "xmlrpc.so"
#!endif

# -- For JSONRPC -------------------
#!ifdef WITH_JSONRPC
loadmodule "jsonrpcs.so"
#!endif

Add the following around line 450

#!ifdef WITH_XMLRPC
# ----- xmlrpc params -----
modparam("xmlrpc", "route", "XMLRPC")
modparam("xmlrpc", "url_match", "^/RPC")
#!endif

#!ifdef WITH_JSONRPC
# ----- jsonrpcs params -----
modparam("jsonrpcs", "dgram_socket", "/var/run/kamailio/kamailio_rpc.sock")
modparam("jsonrpcs", "dgram_mode", 0666)
#!endif
Add the following around line #470 at the end of the modparam section before the routing logic section.
# -- for siremis CDRs --------------
modparam("rtimer", "timer", "name=cdr;interval=300;mode=1;")
modparam("rtimer", "exec", "timer=cdr;route=CDRS")
modparam("sqlops", "sqlcon", "cb=>mysql://kamailio:kamailiorw@localhost/kamailio")
Finally, add this at the end of the routing section around line #910
# ======================================================
# Populate CDRs Table of Siremis
# ======================================================
route[CDRS] {
    sql_query("cb","call kamailio_cdrs()","rb");
    sql_query("cb","call kamailio_rating('default')","rb");
    }


# XMLRPC routing
#!ifdef WITH_XMLRPC
route[XMLRPC] {
    # allow XMLRPC from localhost
    if ((method=="POST" || method=="GET")
            && (src_ip==127.0.0.1)) {
        # close connection only for xmlrpclib user agents (there is a bug in
        # xmlrpclib: it waits for EOF before interpreting the response).
        if ($hdr(User-Agent) =~ "xmlrpclib")
            set_reply_close();
        set_reply_no_connect();
        dispatch_rpc();
        exit;
    }
    send_reply("403", "Forbidden");
    exit;
}
#!endif
Pointing SIP clients to a FQDN instead of an IP address requires a local alias.  The commented out example is located around line #170 in /etc/kamailio/kamailio.cfg.   You can specify multiple aliases by repeating that line
/* add local domain aliases */
alias="your_server_fqdn"
alias="your_server_fqdn2"
systemctl restart kamailio

Siremis

cd /var/www
git clone https://github.com/asipto/siremis

Create apache config file.  

cat >> /etc/apache2/sites-available/siremis.conf << EOF
<VirtualHost *:80>

    #ServerName www.example.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog /var/log/apache2/error.log
    CustomLog /var/log/apache2/access.log combined

    Alias /siremis "/var/www/siremis/siremis"
    <Directory "/var/www/siremis/siremis">
    
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted

            <FilesMatch "\.xml$">
                Require all denied
            </FilesMatch>

            <FilesMatch "\.inc$">
                Require all denied
            </FilesMatch>

      </Directory>

</VirtualHost>
EOF
a2dissite 000-default
a2ensite siremis
a2enmod rewrite
systemctl restart apache2

Create Siremis configs and set permissions

cd /var/www/siremis
make prepare24
make chown

Create MySQL user

mysql -e "GRANT ALL PRIVILEGES ON siremis.* TO siremis@localhost IDENTIFIED BY 'siremisrw';"

Lock down the database

mysql_secure_installation

Answer Y to everything.

 

Run the web install wizard from a web browser at http://your_server_ip_or_fqdn/siremis

If you want to run the install wizard again
chmod 755 /var/www/siremis/siremis/install
rm -rf /var/www/siremis/siremis/install.lock

Otherwise

chmod 000 /var/www/siremis/siremis/install

Administration

Change admin password and email



Add SIP users



Misc

Firewall

apt -y install firewalld
systemctl enable firewalld
systemctl start firewalld

firewall-cmd --permanent --zone=public --add-service={http,https}
firewall-cmd --permanent --zone=public --add-port={5060,5061}/tcp
firewall-cmd --permanent --zone=public --add-port={5060,5061}/udp
firewall-cmd --reload
firewall-cmd --list-all

Log file

To write Kamailio logs to a separate log file in addition to /var/log/syslog.

## Add the following line to /etc/rsyslog.conf
local0.*             -/var/log/kamailio.log
touch /var/log/kamailio.log
systemctl restart rsyslog

References:
Siremis v5.1.x - Installation






Comments

Popular posts from this blog

Vicidial Scratch installation Alma -9

Step 1 – Download the dependencies   hostnamectl set-hostname xxxxxx.xxxxx.xxx ### Use YOUR SubDomain vi /etc/hosts ##Change domain name for actual server ip (xxx.xxx.xxx.xxx   complete domain name    subdomain only) timedatectl set-timezone Asia/Kolkata yum check-update yum update -y yum -y install epel-release yum update -y yum install git -y yum install -y kernel* sudo dnf install kernel-devel-$(uname -r) -y #Disable SELINUX sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config     reboot Step 2 – Run the Script cd /usr/src/ git clone https://github.com/manish23k/vicidial-install-scripts cd vicidial-install-scripts ####For PHP 7.4 use this script. chmod +x alma-rocky9-ast16.sh ./alma-rocky9-ast16.sh Or the Asterisk 18 version: chmod +x alma-rocky9-ast18.sh ./alma-rocky9-ast18.sh ####For PHP 8 use this script. chmod +x main-installer-php8.sh ./main-installer-php8.sh

How to delete old call logs and other logs in vicidial or goautodial.

Step 1 : SSH to the server using the Putty Step 2:   login to mysql by typing   mysql -p                    (if you dont know password try below command )               mysql -ucron -p1234 Step 3 : select the asterisk database by typing               use asterisk step 4: Run the below command to check total disk occupied by asterisk database                SELECT table_schema AS "asterisk", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema; Step 5 : Run the below command to check disk space consumed by each table in asterisk database SELECT table_name AS "Table", ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "asterisk" ORDER BY (data_length + inde...

Alma 9 Vicidial Selfsign Webrtc

I am going to provide step by step guide to integrate, enable and configure the viciphone(a webrtc phone) in vicidial (also applicable to any vicidial based system) using the Self Signed SSL Certificate ,ie without a public-ip and FQDN or accessing the vicidial with internal LAN IP. 1️⃣ Install OpenSSL (if not installed) sudo dnf install -y openssl 2️⃣ Generate a Private Key openssl genpkey -algorithm RSA -out selfsigned.key -pkeyopt rsa_keygen_bits:2048 3️⃣ Create a Certificate Signing Request (CSR) openssl req -new -key selfsigned.key -out selfsigned.csr It will prompt you for details like: Country Name (e.g., IN ) State or Province (e.g., Gujarat ) Locality (City) Organization Name Common Name (Domain, e.g., example.com or your server IP) Email Address You can use localhost or an IP address if needed. 4️⃣ Generate a Self-Signed Certificate openssl x509 -req -days 365 -in selfsigned.csr -signkey selfsigned.key -out selfsigned.crt -days 365 → Valid for 1 year (Adjust as needed) ...