Install And Maintain Kamailio v4.3.x From GIT

Main author:
Daniel-Constantin Mierla <miconda (at) gmail.com>

This is a step by step tutorial about how to install and maintain Kamailio SIP Server version 4.3.x using the sources downloaded from GIT repository - the choice for those willing to write code for Kamailio or to try the new features to be released in the future with the next major stable version.

This document focuses on Kamailio v4.3.x with MySQL support, using a Debian unstable system.

The first version in release series 4.3 is 4.3.0, 4.3.x refers to the most recent version released at some point in time that starts with 4.3.

Note that Kamailio provides APT repositories for several Debian/Ubuntu releases, you can use them to do the install from .deb packages, see:

Notes on Kamailio vs SER

Since version 4.0.0, Kamailio and SER integration was fully completed, there are no more duplicated modules and a single database schema. Default flavour is kamailio, setting this name to the application and database. SER flavour can be compiled using make command line options (practically, flavour system is now just about naming the application and related components).

1. Prerequisites

To be able to follow the guidelines from this document you need root access.

The following packages are required before proceeding to the next steps.

git client: apt-get install git - it is recommended to have a recent version, if your Linux distro has an old version, you can download newer one from: http://git-scm.com/

gcc compiler: apt-get install gcc

flex - apt-get install flex

bison - apt-get install bison

libmysqlclient-dev - apt-get install libmysqlclient-dev

make - apt-get install make

if you want to enable more modules, some of them require extra libraries:

libssl - apt-get install libssl-dev

libcurl - apt-get install libcurl4-openssl-dev

libxml2 - apt-get install libxml2-dev

libpcre3 - apt-get install libpcre3-dev

Important Note: starting with version 4.3.0, Kamailio uses the directory /var/run/kamailio/ for creating FIFO and UnixSocket control files. You have to complete the section related to installation of init.d script for creating /var/run/kamailio even if you plan to start Kamailio manually from command line. The alternative is to set different paths via parameters of mi_fifo and ctl modules.

2. Getting sources from GIT

First of all, you have to create a directory on the file system where the sources will be stored.

Note: if your git client version does not support –no-single-branch command line parameter, then just remove it.

3.Tuning Makefiles

The first step is to generate build config files.

make cfg

Next step is to enable the MySQL module. Edit modules.lst file:

nano -w modules.lst

Add db_mysql to the variable include_modules.

include_modules= db_mysql

Save the modules.lst and exit.

NOTE: this is one mechanism to enable modules which are not compiled by default, such as lcr, dialplan, presence – add the modules to include_modules variable inside the modules.lst file.

Alternative is to set 'include_modules' variable to specify what extra modules to be included for compilation when building Makefile cfg:

make include_modules="db_mysql dialplan" cfg

NOTE: If you want to install everything in one directory (so you can delete all installed files at once), say /usr/local/kamailio-4.3, then set PREFIX variable to the install path in 'make cfg …' command:

NOTE: Previous release series 3.x.x used FLAVOUR mechanism to set the name of the application to kamailio. Starting with 4.0.0, the default is kamailio. From that version, if you want to build ser flavour, use FLAVOUR=ser in the make command to generate the build configs.

4. Compile Kamailio

Once you added the mysql module to the list of enabled modules, you can compile Kamailio:

make all

You can get full compile flags output using:

make Q=0 all

5. Install Kamailio

When the compilation is ready, install Kamailio with the following command:

To be able to use the binaries from command line, make sure that '/usr/local/sbin' is set in PATH environment variable. You can check that with 'echo $PATH'. If not and you are using 'bash', open '/root/.bash_profile' and at the end add:

PATH=$PATH:/usr/local/sbin
export PATH

Kamailio (OpenSER) modules are installed in:

/usr/local/lib/kamailio/modules/

Note: On 64 bit systems, /usr/local/lib64 may be used.

The documentation and readme files are installed in:

/usr/local/share/doc/kamailio/

The man pages are installed in:

/usr/local/share/man/man5/
/usr/local/share/man/man8/

The configuration file was installed in:

/usr/local/etc/kamailio/kamailio.cfg

NOTE; In case you set the PREFIX variable in 'make cfg …' command, then replace /usr/local in all paths above with the value of PREFIX in order to locate the files installed.

7. Create MySQL database

To create the MySQL database, you have to use the database setup script. First edit kamctlrc file to set the database server type:

nano -w /usr/local/etc/kamailio/kamctlrc

Locate DBENGINE variable and set it to MYSQL:

DBENGINE=MYSQL

You can change other values in kamctlrc file, at least it is recommended to change the default passwords for the users to be created to connect to database.

Once you are done updating kamctlrc file, run the script to create the database used by Kamailio:

/usr/local/sbin/kamdbctl create

You can call this script without any parameter to get some help for the usage. You will be asked for the domain name Kamailio is going to serve (e.g., mysipserver.com) and the password of the 'root' MySQL user. The script will create a database named 'kamailio' containing the tables required by Kamailio. You can change the default settings in the kamctlrc file mentioned above.

12. Time for maintenance service

Notification about GIT commits are sent to the mailing list: sr-dev@lists.sip-router.org. Each commit notification contains the reference to the branch where the commit has been done. If the commit message contains the lines:

Module: kamailio
Branch: 4.3

then an update has been made to Kamailio devel version and it will be available to the public GIT in no time.